Преглед на файлове

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

dzx преди 11 месеца
родител
ревизия
154a85f409

+ 2 - 2
src/main/java/com/xjrsoft/common/enums/IssueModeEnum.java

@@ -10,12 +10,12 @@ public enum IssueModeEnum {
     /**
      * 学生
      * */
-    Imtudent("im_student", "学生"),
+    Imtudent("im_student", "学生领取"),
 
     /**
      * 教师
      * */
-    ImTeacher("im_teacher", "教师"),
+    ImTeacher("im_teacher", "教师领取"),
 
     /**
      * 退还

+ 32 - 2
src/main/java/com/xjrsoft/common/utils/SortCodeUtil.java

@@ -1,15 +1,45 @@
 package com.xjrsoft.common.utils;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.toolkit.SimpleQuery;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.poi.ss.formula.functions.T;
 
+import java.util.Optional;
+
 /**
  * @author dzx
  * @date 2024/1/8
  */
 public class SortCodeUtil {
-    public Integer getMaxSortCode(T mapper, T Entity){
-        return null;
+    /**
+     * 获取指定实体的最大排序码(sort_code)。如果不存在,则返回0。
+     *
+     * @param <T>            实体类型
+     * @param mapper         对应的Mapper接口
+     * @param entityClass    实体类的Class对象
+     * @param sortCodeField  排序列名
+     * @return 最大排序码或0
+     */
+    public static <T> Integer getMaxSortCode(Object mapper, Class<T> entityClass, String sortCodeField) {
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("IFNULL(MAX(" + sortCodeField + "), 0) as sortCode");
+
+        // 使用反射调用selectOne方法
+        try {
+            T result = (T) mapper.getClass()
+                    .getMethod("selectOne", QueryWrapper.class)
+                    .invoke(mapper, queryWrapper);
+
+            if (result != null) {
+                // 假设实体有一个名为getSortCode的方法来获取排序码
+                Optional<Integer> sortCode = Optional.ofNullable((Integer) entityClass.getMethod("getSortCode").invoke(result));
+                return sortCode.orElse(0);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return 0;
     }
 }

+ 50 - 10
src/main/java/com/xjrsoft/module/base/service/impl/BaseClassCourseServiceImpl.java

@@ -1,8 +1,10 @@
 package com.xjrsoft.module.base.service.impl;
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
 import com.xjrsoft.module.base.dto.ClassCourseReuseDto;
@@ -12,6 +14,11 @@ import com.xjrsoft.module.base.entity.CourseBookInfo;
 import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
 import com.xjrsoft.module.base.service.IBaseClassCourseService;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.student.entity.SchoolRollStudent;
+import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
+import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
+import com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -22,6 +29,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 /**
 * @title: 班级课程
@@ -34,6 +42,10 @@ import java.util.TreeMap;
 public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCourseMapper, BaseClassCourse> implements IBaseClassCourseService {
     private final BaseClassCourseMapper baseClassCourseMapper;
 
+    private final BaseStudentSchoolRollMapper baseStudentSchoolRollMapper;
+
+    private final TextbookStudentClaimMapper textbookStudentClaimMapper;
+
     @Override
     public Page<BaseClassCoursePageVo> getPage(Page<BaseClassCoursePageVo> page, BaseClassCoursePageDto dto) {
         return baseClassCourseMapper.getPage(page, dto);
@@ -67,31 +79,59 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
         ;
         isSuccess = this.remove(baseClassCourseLambdaQueryWrapper);
 
+
+        // 获取所有班级的所有学生
+        LambdaQueryWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        baseStudentSchoolRollLambdaQueryWrapper
+                .in(BaseStudentSchoolRoll::getClassId, classIdList)
+                .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
+                ;
+        List<BaseStudentSchoolRoll> baseStudentSchoolRolls = baseStudentSchoolRollMapper.selectList(baseStudentSchoolRollLambdaQueryWrapper);
+
+        Map<Long, List<Long>> userIdsMap = baseStudentSchoolRolls.stream()
+                .filter(student -> student.getClassId() != null && student.getUserId() != null)
+                .collect(Collectors.groupingBy(
+                                BaseStudentSchoolRoll::getClassId, // 根据classId分组
+                                Collectors.mapping(BaseStudentSchoolRoll::getUserId, // 提取userId
+                                        Collectors.toList()) // 收集到List<Long>
+                        )
+                );
+
         List<BaseClassCourse> baseClassCourseList = new ArrayList<>();
-        for (Long classId : dto.getClassIds()){
-            for (String id : dto.getIds()){
+        List<TextbookStudentClaim> textbookStudentClaimList = new ArrayList<>();
+        for (Long classId : dto.getClassIds()) {
+            for (String id : dto.getIds()) {
                 String[] idArr = id.split("_");
-                if(idArr[0].equals("") || idArr[1].equals("")){
+                if (idArr[0].equals("") || idArr[1].equals("")) {
                     continue;
                 }
                 Long courseId = Long.parseLong(idArr[0]);
                 Long textbookId = Long.parseLong(idArr[1]);
-                baseClassCourseList.add(new BaseClassCourse(){{
+                baseClassCourseList.add(new BaseClassCourse() {{
                     setBaseSemesterId(dto.getBaseSemesterId());
                     setClassId(classId);
                     setCourseId(courseId);
                     setTextbookId(textbookId);
                 }});
+
+                // 添加学生领取教材数据
+                List<Long> userIds = userIdsMap.get(classId);
+                for (Long userId : userIds) {
+                    textbookStudentClaimList.add(new TextbookStudentClaim() {{
+                        setStudentUserId(userId);
+                        setBaseSemesterId(dto.getBaseSemesterId());
+                        setClassId(classId);
+                        setTextbookId(textbookId);
+                    }});
+                }
             }
         }
 
-        isSuccess = this.saveBatch(baseClassCourseList);
-
-        // TODO 课程教材添加成功,添加领取状态
-
+        for (TextbookStudentClaim textbookStudentClaim : textbookStudentClaimList) {
+            textbookStudentClaimMapper.insert(textbookStudentClaim);
+        }
+        return this.saveBatch(baseClassCourseList);
 
-        return isSuccess;
-        //baseClassCourseMapper.updateAddClassCourseTextbooks(classId, courseId, textbookId);
     }
 
     @Override

+ 5 - 0
src/main/java/com/xjrsoft/module/base/vo/BaseClassCoursePageVo.java

@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ContentStyle;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -62,6 +63,10 @@ public class BaseClassCoursePageVo {
     @ExcelProperty("对应教材")
     private String textbookName;
 
+    @ApiModelProperty("总定价")
+    @ExcelProperty("总定价")
+    private BigDecimal totalPrice;
+
     @ApiModelProperty("学期")
     @ExcelProperty("学期")
     private String semester;

+ 2 - 2
src/main/java/com/xjrsoft/module/textbook/controller/TextbookController.java

@@ -244,8 +244,8 @@ public class TextbookController {
 
     @PostMapping("/textbook-import")
     @ApiOperation(value = "教材信息导入")
-    public RT<Boolean> textbook(@RequestParam MultipartFile file) throws IOException, IllegalAccessException {
-        String result = textbookService.textbook(file);
+    public RT<Boolean> textbookImport(@RequestParam MultipartFile file) throws IOException, IllegalAccessException {
+        String result = textbookService.textbookImport(file);
         if (!result.isEmpty()) {
             throw new MyException(result);
         }

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

@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.Date;
 
 @Data
@@ -102,9 +103,9 @@ public class TextbookImportDto {
      * 出版日期
      */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("出版日期")
+    @ExcelProperty("出版日期(YYYY-MM-DD)")
     @ApiModelProperty("出版日期")
-    private Date publishingDate;
+    private LocalDate publishingDate;
     /**
      * 是否为校企合作教材
      */

+ 1 - 1
src/main/java/com/xjrsoft/module/textbook/service/ITextbookService.java

@@ -132,5 +132,5 @@ public interface ITextbookService extends MPJBaseService<Textbook> {
 
     List<TextbookSubscriptionListVo> getSubscriptionListByClass(TextbookSubscriptionListDto dto);
 
-    String textbook(MultipartFile file) throws IOException, IllegalAccessException;
+    String textbookImport(MultipartFile file) throws IOException, IllegalAccessException;
 }

+ 10 - 6
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java

@@ -113,6 +113,8 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
             throw new MyException("issn,学科组,课程为必填字段");
         }
 
+        textbook.setIsbn(textbook.getIssn());
+
         // 判断导入的教材是否已经存在,根据教材的 ISSN 码和使用的学科组和课程判断
         LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
         textbookLambdaQueryWrapper
@@ -1188,7 +1190,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String textbook(MultipartFile file) throws IOException, IllegalAccessException {
+    public String textbookImport(MultipartFile file) throws IOException, IllegalAccessException {
         List<TextbookImportDto> excelDataList = EasyExcel.read(file.getInputStream()).headRowNumber(3).head(TextbookImportDto.class).sheet().doReadSync();
         StringBuilder sb = new StringBuilder();
 
@@ -1220,7 +1222,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
             TextbookImportDto dto = excelDataList.get(i);
             if (isRequiredFieldsFilled(dto,
                     sb,
-                    i)) {
+                    i+2)) {
                 return sb.toString();
             }
 
@@ -1235,7 +1237,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     dictionary,
                     textbook::setTextbookType,
                     sb,
-                    i)) {
+                    i+2)) {
                 return sb.toString();
             }
             if (validateAndSetDictionaryField(dto::getTextbookCategory,
@@ -1244,7 +1246,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     dictionary,
                     textbook::setTextbookCategory,
                     sb,
-                    i)) {
+                    i+2)) {
                 return sb.toString();
             }
 
@@ -1254,7 +1256,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     subjectGroupNameAndIdMap,
                     textbook::setSubjectGroupId,
                     sb,
-                    i
+                    i+2
             )) {
                 return sb.toString();
             }
@@ -1263,7 +1265,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     baseCourseSubjectNameAndIdMap,
                     textbook::setCourseSubjectId,
                     sb,
-                    i
+                    i+2
             )) {
                 return sb.toString();
             }
@@ -1293,6 +1295,8 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
             ;
 
             Textbook verifyTextbook = this.getOne(textbookLambdaQueryWrapper);
+
+            textbook.setIsbn(textbook.getIssn());
             if(ObjectUtils.isNotEmpty(verifyTextbook)){
                 textbook.setId(verifyTextbook.getId());
                 updateTextbooks.add(textbook);

+ 4 - 0
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookSubscriptionServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.textbook.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -246,6 +247,9 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
         // 处理征订表
         int sum = 0;
         for (TextbookSubscriptionItem textbookSubscriptionItem : textbookSubscription.getTextbookSubscriptionItemList()) {
+            textbookSubscriptionItem.setStudentNum(ObjectUtil.isNull(textbookSubscriptionItem.getStudentNum()) ? 0 : textbookSubscriptionItem.getStudentNum());
+            textbookSubscriptionItem.setTeacherNum(ObjectUtil.isNull(textbookSubscriptionItem.getTeacherNum()) ? 0 : textbookSubscriptionItem.getTeacherNum());
+
             sum += textbookSubscriptionItem.getStudentNum() + textbookSubscriptionItem.getTeacherNum();
         }
         textbookSubscriptionTextbookSubscriptionMapper.insert(textbookSubscription);

+ 62 - 60
src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookClaimServiceImpl.java

@@ -11,20 +11,14 @@ 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.common.utils.SortCodeUtil;
 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;
 import com.xjrsoft.module.textbook.dto.WfTextbookClaimPageDto;
-import com.xjrsoft.module.textbook.entity.Textbook;
-import com.xjrsoft.module.textbook.entity.TextbookClaimUser;
-import com.xjrsoft.module.textbook.entity.TextbookIssueRecord;
-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.TextbookClaimUserMapper;
-import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
-import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
+import com.xjrsoft.module.textbook.entity.*;
+import com.xjrsoft.module.textbook.mapper.*;
 import com.xjrsoft.module.textbook.service.ITextbookIssueRecordService;
 import com.xjrsoft.module.textbook.service.ITextbookService;
 import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
@@ -33,6 +27,7 @@ import com.xjrsoft.module.textbook.vo.WfTextbookClaimItemVo;
 import com.xjrsoft.module.textbook.vo.WfTextbookClaimPageVo;
 import com.xjrsoft.module.textbook.vo.WfTextbookClaimVo;
 import lombok.AllArgsConstructor;
+import org.glassfish.jersey.server.internal.process.MappableException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -57,13 +52,13 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
 
     private final XjrUserMapper xjrUserMapper;
 
-    private final RoleMapper roleMapper;
+    private final TextbookMapper textbookMapper;
 
-    private final ITextbookService textbookService;
+    private final TextbookStudentClaimMapper textbookStudentClaimMapper;
 
-    private final ITextbookStudentClaimService textbookStudentClaimService;
+    private final TextbookSubscriptionItemMapper textbookSubscriptionItemMapper;
 
-    private final ITextbookIssueRecordService textbookIssueRecordService;
+    private final TextbookIssueRecordMapper textbookIssueRecordMapper;
 
     private final TextbookClaimUserMapper textbookClaimUserMapper;
 
@@ -213,11 +208,15 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
             WfTextbookClaimItem wfTextbookClaimItem = wfTextbookClaimWfTextbookClaimItemMapper.selectById(textbookClaimItem.getTextbookClaimItemId());
 
             if (ObjectUtil.isNull(wfTextbookClaimItem)) {
-                throw new MyException("未找到申领数据");
+                throw new MyException("未找到申领项详细数据");
             }
 
-            Textbook textbook = textbookService.getById(wfTextbookClaimItem.getTextbookId());
+            TextbookSubscriptionItem textbookSubscriptionItem = textbookSubscriptionItemMapper.selectById(textbookClaimItem.getTextbookSubscriptionItemId());
+            if (ObjectUtil.isNull(textbookSubscriptionItem)) {
+                throw new MyException("未找到征订项详细数据");
+            }
 
+            Textbook textbook = textbookMapper.selectById(textbookSubscriptionItem.getTextbookId());
             if (ObjectUtil.isNull(textbook)) {
                 throw new MyException("未找到相关教材数据");
             }
@@ -230,37 +229,41 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
                 throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
             }
 
-            //判断发放量是否多于库存量
-
             //增加出库记录
-            textbookIssueRecordService.save(new TextbookIssueRecord() {{
+            textbookIssueRecordMapper.insert(new TextbookIssueRecord() {{
                 setCreateDate(new Date());
-                setTextbookId(wfTextbookClaimItem.getTextbookId());
-                setDataId(wfTextbookClaim.getId());
-                setDataItemId(wfTextbookClaimItem.getId());
-                setIssueNumber(confirmNumber);
-                setRemainingNumber(applicantNumber - issueNumber - confirmNumber);
-                setReceiveUserId(dto.getReceiveUserId());
-                setIssueUserId(StpUtil.getLoginIdAsLong());
                 if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
                     setIssueMode(IssueModeEnum.Imtudent.getCode());
                 }
                 if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimTeacher.getCode())) {
                     setIssueMode(IssueModeEnum.ImTeacher.getCode());
                 }
+
+                setDataId(wfTextbookClaim.getId());
+                setDataItemId(wfTextbookClaimItem.getId());
+
+                setTextbookId(wfTextbookClaimItem.getTextbookId());
+                setIssueNumber(confirmNumber);
+
+                setRemainingNumber(applicantNumber - issueNumber - confirmNumber);
+
+                setReceiveUserId(dto.getReceiveUserId());
+                setIssueUserId(StpUtil.getLoginIdAsLong());
+
                 setRemark(dto.getRemark());
-                QueryWrapper<TextbookIssueRecord> queryWrapperSortcode = new QueryWrapper<>();
-                queryWrapperSortcode.select("IFNULL(MAX(sort_code),0) as sortCode");
-                TextbookIssueRecord t = textbookIssueRecordService.getOne(queryWrapperSortcode);
-                setSortCode(t.getSortCode()+1);
+
+                int sortCode = SortCodeUtil.getMaxSortCode(textbookIssueRecordMapper, TextbookIssueRecord.class, "sort_code");
+
+                setSortCode(sortCode + 1);
 
             }});
 
             //更新教材管理中的库存数量
-            textbookService.updateById(new Textbook() {{
+            textbookSubscriptionItemMapper.updateById(new TextbookSubscriptionItem() {{
                 setModifyUserId(StpUtil.getLoginIdAsLong());
                 setModifyDate(new Date());
-                setId(textbook.getId());
+                setId(textbookSubscriptionItem.getId());
+                setOutStockNum(confirmNumber);
             }});
 
             //更新申领项中的已经发放数量
@@ -271,35 +274,34 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
                 setIssueNumber(issueNumber + confirmNumber);
             }});
 
-
-            //当申领类型为学生的时候,为班级每个学生生成领取(确认信息)认领记录
-            if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
-                //查出班上的所有学生id
-                List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
-
-                if (ObjectUtil.isNull(userIdList) && userIdList.size() == 0) {
-                    throw new MyException("申领班级有误,请核实");
-                }
-                //验证当前领取教材是否已经生成领取记录
-                LambdaQueryWrapper<TextbookStudentClaim> queryWrapperRecord = new LambdaQueryWrapper<>();
-                queryWrapperRecord
-                        .eq(TextbookStudentClaim::getTextbookId, wfTextbookClaimItem.getTextbookId())
-                        .eq(TextbookStudentClaim::getClassId, wfTextbookClaim.getClassId());
-                Long count = textbookStudentClaimService.count(queryWrapperRecord);
-                //为0的时候表示该班级该书没有生成领取记录
-                if(count <= 0){
-                    for (Long userId : userIdList) {
-                        textbookStudentClaimService.save(new TextbookStudentClaim() {{
-                            setCreateUserId(StpUtil.getLoginIdAsLong());
-                            setCreateDate(new Date());
-                            setStudentUserId(userId);
-                            setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
-                            setClassId(wfTextbookClaim.getClassId());
-                            setTextbookId(wfTextbookClaimItem.getTextbookId());
-                        }});
-                    }
-                }
-            }
+            // 当申领类型为学生的时候,为班级每个学生生成领取(确认信息)认领记录
+//            if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
+//                //查出班上的所有学生id
+//                List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
+//
+//                if (ObjectUtil.isNull(userIdList) && userIdList.size() == 0) {
+//                    throw new MyException("申领班级有误,请核实");
+//                }
+//                //验证当前领取教材是否已经生成领取记录
+//                LambdaQueryWrapper<TextbookStudentClaim> queryWrapperRecord = new LambdaQueryWrapper<>();
+//                queryWrapperRecord
+//                        .eq(TextbookStudentClaim::getTextbookId, wfTextbookClaimItem.getTextbookId())
+//                        .eq(TextbookStudentClaim::getClassId, wfTextbookClaim.getClassId());
+//                Long count = textbookStudentClaimMapper.selectCount(queryWrapperRecord);
+//                //为0的时候表示该班级该书没有生成领取记录
+//                if(count <= 0){
+//                    for (Long userId : userIdList) {
+//                        textbookStudentClaimMapper.insert(new TextbookStudentClaim() {{
+//                            setCreateUserId(StpUtil.getLoginIdAsLong());
+//                            setCreateDate(new Date());
+//                            setStudentUserId(userId);
+//                            setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
+//                            setClassId(wfTextbookClaim.getClassId());
+//                            setTextbookId(wfTextbookClaimItem.getTextbookId());
+//                        }});
+//                    }
+//                }
+//            }
         }
         return true;
     }

+ 10 - 1
src/main/resources/mapper/base/BaseClassCourse.xml

@@ -27,7 +27,16 @@
         <if test="dto.semester != null">
         AND t5.base_semester_id = #{dto.semester}
         </if>
-        ) AS textbook_name
+        ) AS textbook_name,
+        (SELECT sum(t8.price)
+        FROM base_class_course t5
+        LEFT JOIN textbook t8 ON t8.id = t5.textbook_id
+        WHERE t5.class_id = t.id
+        AND t5.delete_mark = 0
+        <if test="dto.semester != null">
+            AND t5.base_semester_id = #{dto.semester}
+        </if>
+        ) AS total_price
         FROM base_class t
         LEFT JOIN xjr_user t1 ON t1.id = t.teacher_id
         LEFT JOIN base_class_major_set t2 ON t2.class_id = t.id

+ 2 - 3
src/main/resources/mapper/textbook/TextbookStudentClaimMapper.xml

@@ -13,11 +13,10 @@
         t1.book_name as bookName,
         t1.price as price
         FROM textbook_student_claim t
-        LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
-        LEFT JOIN base_class_course t2 ON t.textbook_id = t2.textbook_id
+        inner JOIN textbook t1 ON (t1.id = t.textbook_id)
         WHERE t.delete_mark = 0
         AND (t.student_user_id = #{dto.studentUserId})
-        AND (t2.base_semester_id = #{dto.baseSemesterId})
+        AND (t.base_semester_id = #{dto.baseSemesterId})
         <if test="dto.showOrConfirm != null and dto.showOrConfirm == 2">
             and t.is_claim = 0
         </if>

+ 66 - 40
src/main/resources/sqlScript/textbook_sql.sql

@@ -28,7 +28,7 @@ create table `textbook`
     is_textbook_plan      int            null default 0 comment '是否为规划教材',
     textbook_type         varchar(20)    null comment '教材分类(xjr_dictionary_item[textbook_type])',
     specifications_models varchar(100)   null default '/' comment '规格型号',
-    publishing_date       datetime       null comment '出版日期',
+    publishing_date       date       null comment '出版日期',
     is_secd               int            null default 0 comment '是否校企合作开发教材',
     category              varchar(50)    null default '/' comment '分类号',
     plan_batch            varchar(50)    null default '/' comment '规划批次',
@@ -269,32 +269,18 @@ create table `claim_item_subscription_item`
     sort_code            int           null comment '序号',
 
     wf_textbook_claim_item_id bigint        null comment '教材申领编号',
-    textbook_subscription_item_id bigint        null comment '教材申领编号',
+    textbook_subscription_item_id bigint        null comment '教材征订编号',
     issue_number         int default 0 null comment '已发放数量'
 )engine = innodb
  default charset = utf8mb4
  collate = utf8mb4_0900_ai_ci comment ='教材申领项与教材征订项关联表';
 
-# drop table if exists textbook_subscription_record;
-# create table `textbook_subscription_record`
-# (
-#     id                               bigint   not null comment '主键编号'
-#         primary key,
-#     create_user_id                   bigint   null comment '创建人',
-#     create_date                      datetime null comment '创建时间',
-#     modify_user_id                   bigint   null comment '修改人',
-#     modify_date                      datetime null comment '修改时间',
-#     delete_mark                      int      not null comment '删除标记',
-#     enabled_mark                     int      not null comment '有效标志',
-#     sort_code                        int      null comment '序号',
-#
-#     textbook_subscription_id      bigint   null comment '教材征订编号',
-#     textbook_subscription_item_id bigint   null comment '教材征订项编号'
-# ) engine = innodb
-#   default charset = utf8mb4
-#   collate = utf8mb4_0900_ai_ci comment ='教材征订记录';
-
-create table if not exists tl.textbook_claim_user
+-- ----------------------------
+-- 2024-12-13 14:36
+-- 教材领取人员
+-- ----------------------------
+drop table if exists textbook_claim_user;
+create table `textbook_claim_user`
 (
     id                   bigint        not null comment '主键编号'
         primary key,
@@ -305,13 +291,21 @@ create table if not exists tl.textbook_claim_user
     delete_mark          int           not null comment '删除标记',
     enabled_mark         int           not null comment '有效标志',
     sort_code            int           null comment '序号',
+
     wf_textbook_claim_id bigint        null comment '教材申领编号',
+
     user_id              bigint        null comment '用户编号',
     user_type            int default 2 null comment '用户类型(1:学生 2=教师)'
-)
-    comment '教材领取人员';
+)engine = innodb
+ default charset = utf8mb4
+ collate = utf8mb4_0900_ai_ci comment ='教材领取人员';
 
-create table if not exists tl.textbook_issue_record
+-- ----------------------------
+-- 2024-12-13 14:36
+-- 教材出库记录
+-- ----------------------------
+drop table if exists textbook_issue_record;
+create table `textbook_issue_record`
 (
     id               bigint        not null comment '主键编号'
         primary key,
@@ -322,19 +316,29 @@ create table if not exists tl.textbook_issue_record
     delete_mark      int           not null comment '删除标记',
     enabled_mark     int           not null comment '有效标志',
     sort_code        int           null comment '序号',
-    textbook_id      bigint        null comment '教材管理编号',
+
+    issue_mode       varchar(20)   null comment '出库方式(xjr_dictionary_item[issue_mode])',
     data_id          bigint        null comment '数据编号(根据出库方式,编号来自不同数据表)',
     data_item_id     bigint        null comment '数据项项编号(根据出库方式,编号来自不同数据表)',
+
+    textbook_id      bigint        null comment '教材管理编号',
     issue_number     int           null comment '出库数量',
-    remaining_number int           null comment '剩余数量',
+    remaining_number int           null comment '剩余未出库数量',
+
     receive_user_id  bigint        null comment '领取用户编号',
     issue_user_id    bigint        null comment '出库用户编号',
-    issue_mode       varchar(20)   null comment '出库方式(xjr_dictionary_item[issue_mode])',
+
     remark           varchar(1000) null comment '备注'
-)
-    comment '教材出库记录';
+)engine = innodb
+ default charset = utf8mb4
+ collate = utf8mb4_0900_ai_ci comment ='教材出库记录';
 
-create table if not exists tl.textbook_student_claim
+-- ----------------------------
+-- 2024-12-13 14:36
+-- 学生教材认领记录
+-- ----------------------------
+drop table if exists textbook_student_claim;
+create table `textbook_student_claim`
 (
     id               bigint        not null comment '主键编号'
         primary key,
@@ -345,16 +349,24 @@ create table if not exists tl.textbook_student_claim
     delete_mark      int           not null comment '删除标记',
     enabled_mark     int           not null comment '有效标志',
     sort_code        int           null comment '序号',
+
     base_semester_id bigint        null comment '学期id(base_semester)',
     class_id         bigint        null comment '班级编号',
     student_user_id  bigint        null comment '学生用户编号',
+
     textbook_id      bigint        null comment '教材管理编号',
     is_claim         int default 0 not null comment '是否领取(1:已领取 0:未领取)',
     remark           varchar(1000) null comment '备注'
-)
-    comment '学生教材认领记录';
+)engine = innodb
+ default charset = utf8mb4
+ collate = utf8mb4_0900_ai_ci comment ='学生教材认领记录';
 
-create table if not exists tl.wf_textbook_recede
+-- ----------------------------
+-- 2024-12-13 14:36
+-- 退书申请
+-- ----------------------------
+drop table if exists wf_textbook_recede;
+create table `wf_textbook_recede`
 (
     id                bigint        not null comment '主键编号'
         primary key,
@@ -365,16 +377,25 @@ create table if not exists tl.wf_textbook_recede
     delete_mark       int           not null comment '删除标记',
     enabled_mark      int           not null comment '有效标志',
     sort_code         int           null comment '序号',
+
     applicant_user_id bigint        null comment '申请人',
+    recede_type       varchar(20)   null comment '退书类型(xjr_dictionary_item[recede_type])',
+
     base_semester_id  bigint        null comment '学期id(base_semester)',
     class_id          bigint        null comment '班级编号',
-    recede_type       varchar(20)   null comment '退书类型(xjr_dictionary_item[recede_type])',
+
     recede_address    varchar(1000) null comment '退还地点',
     status            int default 0 not null comment '状态(1:结束 0:未结束)'
-)
-    comment '退书申请';
+)engine = innodb
+ default charset = utf8mb4
+ collate = utf8mb4_0900_ai_ci comment ='退书申请';
 
-create table if not exists tl.wf_textbook_recede_item
+-- ----------------------------
+-- 2024-12-13 14:36
+-- 退书申请项
+-- ----------------------------
+drop table if exists wf_textbook_recede_item;
+create table `wf_textbook_recede_item`
 (
     id                    bigint   not null comment '主键编号'
         primary key,
@@ -385,11 +406,16 @@ create table if not exists tl.wf_textbook_recede_item
     delete_mark           int      not null comment '删除标记',
     enabled_mark          int      not null comment '有效标志',
     sort_code             int      null comment '序号',
+
     wf_textbook_recede_id bigint   null comment '退书申请编号',
+
     textbook_id           bigint   null comment '教材管理编号',
     number                int      null comment '数量'
-)
-    comment '退书申请项';
+)engine = innodb
+ default charset = utf8mb4
+ collate = utf8mb4_0900_ai_ci comment ='退书申请项';
+
+
 
 
 

+ 20 - 0
src/test/java/com/xjrsoft/xjrsoftboot/StrTest.java

@@ -28,6 +28,7 @@ import java.time.LocalDateTime;
 import java.time.format.TextStyle;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static java.util.Calendar.DAY_OF_MONTH;
 
@@ -338,4 +339,23 @@ public class StrTest {
         long primaryKey = generateLongPrimaryKey();
         System.err.println(primaryKey);
     }
+
+    @Test
+    public void generateRandomNumbers() {
+        List<Integer> numbers = Arrays.asList(7, 4, 3); // 给定的数字集合
+        int totalNumbers = 210; // 需要生成的总数量
+
+        List<Integer> result = new ArrayList<>();
+        Random random = new Random();
+
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < totalNumbers; i++) {
+            // 从numbers集合中随机选择一个数
+            int index = random.nextInt(numbers.size());
+            result.add(numbers.get(index));
+            sb.append(numbers.get(index));
+        }
+        System.err.println(sb.toString());
+    }
+
 }