Ver Fonte

Merge branch 'pre'

dzx há 1 ano atrás
pai
commit
6e6be7774b
25 ficheiros alterados com 406 adições e 185 exclusões
  1. 2 2
      src/main/java/com/xjrsoft/common/enums/IssueModeEnum.java
  2. 32 2
      src/main/java/com/xjrsoft/common/utils/SortCodeUtil.java
  3. 2 0
      src/main/java/com/xjrsoft/module/base/controller/BaseClassCourseController.java
  4. 2 0
      src/main/java/com/xjrsoft/module/base/service/IBaseClassCourseService.java
  5. 58 10
      src/main/java/com/xjrsoft/module/base/service/impl/BaseClassCourseServiceImpl.java
  6. 5 0
      src/main/java/com/xjrsoft/module/base/vo/BaseClassCoursePageVo.java
  7. 5 0
      src/main/java/com/xjrsoft/module/courseTable/service/impl/CourseTableServiceImpl.java
  8. 0 45
      src/main/java/com/xjrsoft/module/liteflow/node/StudentDropOutNode.java
  9. 2 2
      src/main/java/com/xjrsoft/module/textbook/controller/TextbookController.java
  10. 0 1
      src/main/java/com/xjrsoft/module/textbook/controller/TextbookIssueRecordController.java
  11. 14 1
      src/main/java/com/xjrsoft/module/textbook/controller/TextbookSubscriptionController.java
  12. 27 1
      src/main/java/com/xjrsoft/module/textbook/dto/ConfirmDistributeDto.java
  13. 3 2
      src/main/java/com/xjrsoft/module/textbook/dto/TextbookImportDto.java
  14. 1 1
      src/main/java/com/xjrsoft/module/textbook/dto/TextbookSubscriptionExportQueryListDto.java
  15. 1 1
      src/main/java/com/xjrsoft/module/textbook/service/ITextbookService.java
  16. 2 0
      src/main/java/com/xjrsoft/module/textbook/service/ITextbookSubscriptionService.java
  17. 10 6
      src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java
  18. 61 0
      src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookSubscriptionServiceImpl.java
  19. 79 65
      src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookClaimServiceImpl.java
  20. 1 1
      src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookSubscriptionServiceImpl.java
  21. 10 1
      src/main/resources/mapper/base/BaseClassCourse.xml
  22. 2 3
      src/main/resources/mapper/textbook/TextbookStudentClaimMapper.xml
  23. 66 40
      src/main/resources/sqlScript/textbook_sql.sql
  24. 1 1
      src/test/java/com/xjrsoft/module/liteflow/node/StudentDropOutNodeTest.java
  25. 20 0
      src/test/java/com/xjrsoft/xjrsoftboot/StrTest.java

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

+ 2 - 0
src/main/java/com/xjrsoft/module/base/controller/BaseClassCourseController.java

@@ -32,8 +32,10 @@ import com.xjrsoft.module.base.vo.BaseClassCourseExportListVo;
 import com.xjrsoft.module.base.vo.BaseClassCourseListVo;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
 import com.xjrsoft.module.base.vo.BaseClassCourseVo;
+import com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryListDto;
 import com.xjrsoft.module.textbook.entity.Textbook;
 import com.xjrsoft.module.textbook.service.ITextbookService;
+import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;

+ 2 - 0
src/main/java/com/xjrsoft/module/base/service/IBaseClassCourseService.java

@@ -8,6 +8,8 @@ import com.xjrsoft.module.base.entity.BaseClassCourse;
 import com.xjrsoft.module.base.entity.ClassCourseTextbook;
 import com.xjrsoft.module.base.entity.CourseBookInfo;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
+import com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryListDto;
+import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
 
 import java.util.List;
 import java.util.Map;

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

@@ -3,15 +3,29 @@ package com.xjrsoft.module.base.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
 import com.xjrsoft.module.base.dto.ClassCourseReuseDto;
 import com.xjrsoft.module.base.entity.BaseClassCourse;
+import com.xjrsoft.module.base.entity.BaseCourseSubject;
 import com.xjrsoft.module.base.entity.ClassCourseTextbook;
 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.mapper.BaseStudentSchoolRollMapper;
+import com.xjrsoft.module.system.entity.DictionaryDetail;
+import com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryListDto;
+import com.xjrsoft.module.textbook.entity.Textbook;
+import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
+import com.xjrsoft.module.textbook.entity.TextbookSubscription;
+import com.xjrsoft.module.textbook.entity.WfTextbookSubscriptionItem;
+import com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper;
+import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -22,6 +36,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 /**
 * @title: 班级课程
@@ -32,8 +47,13 @@ import java.util.TreeMap;
 @Service
 @AllArgsConstructor
 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 +87,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;

+ 5 - 0
src/main/java/com/xjrsoft/module/courseTable/service/impl/CourseTableServiceImpl.java

@@ -364,6 +364,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean adjustCourse(WfCourseAdjust courseAdjust){
         //先查询课表数据,看是否能够查询到,如果能查到
         List<CourseTable> list = this.list(
@@ -384,6 +385,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             courseCount += exchangeCourseIds.length;
             courseIdList.addAll(Arrays.asList(exchangeCourseIds));
         }
+        LocalDateTime now = LocalDateTime.now();
 
         if(list.isEmpty() || list.size() != courseCount){
             list = this.list(
@@ -498,6 +500,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 //                            + courseTable.getSiteId() + "_"
 //                            + courseTable.getTimeNumber()
 //                    );
+                    courseTable.setModifyDate(now);
                     courseTableMapper.updateById(courseTable);
 
                     swapCourseTable.setAdjustType(courseAdjust.getAdjustType());
@@ -513,6 +516,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                     swapCourseTable.setTeacherId(courseTableBak.getTeacherId());
                     swapCourseTable.setSiteId(courseTableBak.getSiteId());
                     swapCourseTable.setTeacherName(courseTableBak.getTeacherName());
+                    swapCourseTable.setModifyDate(now);
                     courseTableMapper.updateById(swapCourseTable);
                 }
                 //提交调课接口
@@ -529,6 +533,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                     courseTable.setAdjustType(courseAdjust.getAdjustType());
                     courseTable.setTeacherId(teacherId);
                     courseTable.setTeacherName(teacherName);
+                    courseTable.setModifyDate(now);
 //                    courseTable.setKeyInfo(teacherId + "_" + courseTable.getClassId() + "_" + courseTable.getScheduleDate() + "_" + courseTable.getCourseId() + "_" + courseTable.getSiteId() + "_" + courseTable.getTimeNumber());
                     courseTableMapper.updateById(courseTable);
                 }

+ 0 - 45
src/main/java/com/xjrsoft/module/liteflow/node/StudentDropOutNode.java

@@ -3,16 +3,9 @@ package com.xjrsoft.module.liteflow.node;
 import cn.hutool.core.convert.Convert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.WorkflowApproveType;
-import com.xjrsoft.module.hikvision.entity.HikvisionData;
-import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
-import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.StudentDropOut;
 import com.xjrsoft.module.student.mapper.StudentDropOutMapper;
@@ -28,11 +21,9 @@ import org.springframework.stereotype.Component;
 import org.springframework.transaction.support.TransactionSynchronization;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 
 /**
@@ -51,8 +42,6 @@ public class StudentDropOutNode extends NodeComponent {
     @Autowired
     private WorkflowRecordMapper workflowRecordMapper;
 
-    @Autowired
-    private HikvisionDataMapper hikvisionDataMapper;
 
     @Override
     public void process() throws Exception {
@@ -104,40 +93,6 @@ public class StudentDropOutNode extends NodeComponent {
                         );
                         schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
                         studentSchoolRollService.updateById(schoolRoll);
-
-                        //删除海康出入权限
-                        String hikvisionId = hikvisionDataMapper.getStudentHikvisionId(studentDropOut.getStudentUserId());
-                        ApiUtil apiUtil = new ApiUtil();
-                        String apiPath = "/api/pmas/v1/person/batch/delete";
-                        JsonObject paramJson = new JsonObject();
-                        JsonArray personIndexCodes = new JsonArray();
-                        personIndexCodes.add(hikvisionId);
-                        paramJson.add("personIndexCodes", personIndexCodes);
-                        String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
-
-                        JsonParser parser = new JsonParser();
-                        JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
-                        if(resultJson.get("code").getAsInt() == 0){
-                            JsonArray success = resultJson.get("data").getAsJsonObject().get("success").getAsJsonArray();
-
-                            Set<String> valuesSet = new HashSet<>();
-                            String keyToExtract = "indexCode";
-                            // 遍历 JSON 数组并提取指定键的值
-                            for (JsonElement jsonElement : success) {
-                                JsonObject jsonObject = jsonElement.getAsJsonObject();
-                                if (jsonObject.has(keyToExtract)) {
-                                    String value = jsonObject.get(keyToExtract).getAsString();
-                                    valuesSet.add(value);
-                                }
-                            }
-                            if(valuesSet.contains(hikvisionId)){
-                                hikvisionDataMapper.delete(
-                                        new QueryWrapper<HikvisionData>().lambda()
-                                                .eq(HikvisionData::getSourceId, studentDropOut.getStudentUserId())
-                                                .eq(HikvisionData::getHikvisionId, hikvisionId)
-                                );
-                            }
-                        }
                     });
                 }
             });

+ 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);
         }

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

@@ -72,7 +72,6 @@ public class TextbookIssueRecordController {
         return RT.ok(BeanUtil.toBean(textbookIssueRecord, TextbookIssueRecordVo.class));
     }
 
-
     @PostMapping
     @ApiOperation(value = "新增教材出库记录")
     @SaCheckPermission("textbookissuerecord:add")

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

@@ -144,7 +144,7 @@ public class TextbookSubscriptionController {
     }
 
     @GetMapping(value = "/item-list-confirm-distribute")
-    @ApiOperation(value="确认教材页面使用教材征订明细(不分页)")
+    @ApiOperation(value="教材确认发放页面使用教材征订明细(不分页)")
     @SaCheckPermission("textbooksubscription:detail")
     public RT<List<SubscriptionItemListDistributeVo>> itemListConfirmDistribute(@Valid SubscriptionItemListDistributeDto dto){
         List<SubscriptionItemListDistributeVo> list = textbookSubscriptionService.itemListConfirmDistribute(dto);
@@ -213,6 +213,19 @@ public class TextbookSubscriptionController {
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
         EasyExcel.write(bot, TextbookSubscriptionListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
 
+        return RT.fileStream(bot.toByteArray(), "TextbookSubscription" + ExcelTypeEnum.XLSX.getValue());
+    }
+
+//    @PostMapping("/textbook-subscription-export-query")
+//    @ApiOperation(value = "教材征订条件导出")
+//    public ResponseEntity<byte[]> textbookSubscriptionExportQuery(@Valid @RequestBody TextbookSubscriptionExportQueryListDto dto) {
+    @GetMapping("/textbook-subscription-export-query")
+    @ApiOperation(value = "教材征订条件导出")
+    public ResponseEntity<byte[]> textbookSubscriptionExportQuery(@Valid TextbookSubscriptionExportQueryListDto dto) {
+        List<TextbookSubscriptionExportQueryListVo> customerList = textbookSubscriptionService.textbookSubscriptionExportQuery(dto);
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        EasyExcel.write(bot, TextbookSubscriptionExportQueryListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
+
         return RT.fileStream(bot.toByteArray(), "TextbookSubscription" + ExcelTypeEnum.XLSX.getValue());
     }
 }

+ 27 - 1
src/main/java/com/xjrsoft/module/textbook/dto/ConfirmDistributeDto.java

@@ -48,12 +48,38 @@ public class ConfirmDistributeDto{
 
         private static final long serialVersionUID = 1L;
 
+        /**
+         * 教材主键编号
+         */
+        @ApiModelProperty("教材主键编号")
+        private Long textbookId;
+
         /**
          * 教材申领项主键编号
          */
         @ApiModelProperty("教材申领项主键编号")
         private Long textbookClaimItemId;
 
+        /**
+         * 教材征订项主键编号
+         */
+        @ContentStyle(dataFormat = 49)
+        @ExcelProperty("教材征订项主键编号")
+        @ApiModelProperty("教材征订项主键编号")
+        private List<TextbookSubscriptionItems> textbookSubscriptionItems;
+
+        /**
+         * 发放数量
+         */
+        @ApiModelProperty("本次发放本书总数量")
+        private Integer confirmTotalNumber;
+    }
+
+    @Data
+    public static class TextbookSubscriptionItems implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
         /**
          * 教材征订项主键编号
          */
@@ -65,7 +91,7 @@ public class ConfirmDistributeDto{
         /**
          * 发放数量
          */
-        @ApiModelProperty("本次发放数量")
+        @ApiModelProperty("本次发放本书本征订记录中的数量")
         private Integer confirmNumber;
     }
 }

+ 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/dto/TextbookSubscriptionExportQueryListDto.java

@@ -16,5 +16,5 @@ public class TextbookSubscriptionExportQueryListDto {
      * 教材教辅征订编号
      */
     @ApiModelProperty("教材教辅征订编号")
-    private Long wfTextbookSubscriptionId;
+    private Long textbookSubscriptionId;
 }

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

+ 2 - 0
src/main/java/com/xjrsoft/module/textbook/service/ITextbookSubscriptionService.java

@@ -76,4 +76,6 @@ public interface ITextbookSubscriptionService extends MPJBaseService<TextbookSub
     * @return
     */
     Boolean delete(List<Long> ids);
+
+    List<TextbookSubscriptionExportQueryListVo> textbookSubscriptionExportQuery(TextbookSubscriptionExportQueryListDto dto);
 }

+ 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);

+ 61 - 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);
@@ -500,4 +504,61 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
         textbookSubscriptionClassMapper.delete(Wrappers.lambdaQuery(TextbookSubscriptionClass.class).in(TextbookSubscriptionClass::getTextbookSubscriptionId, ids));
         return true;
     }
+
+    @Override
+    public List<TextbookSubscriptionExportQueryListVo> textbookSubscriptionExportQuery(TextbookSubscriptionExportQueryListDto dto) {
+        TextbookSubscription textbookSubscription = this.getById(dto.getTextbookSubscriptionId());
+        if (textbookSubscription == null) {
+            return null;
+        }
+
+        MPJLambdaWrapper<TextbookSubscriptionItem> textbookSubscriptionItemMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        textbookSubscriptionItemMPJLambdaWrapper
+                .selectAs(BaseCourseSubject::getName, TextbookSubscriptionExportQueryListVo::getCourseName)
+                .selectAs(TextbookSubscriptionItem::getStudentNum, TextbookSubscriptionExportQueryListVo::getStudentSubscriptionNumber)
+                .selectAs(TextbookSubscriptionItem::getTeacherNum, TextbookSubscriptionExportQueryListVo::getTeacherSubscriptionNumber)
+                .selectAs(TextbookSubscriptionItem::getInStockNum, TextbookSubscriptionExportQueryListVo::getInStockroomNum)
+                .selectAs(TextbookSubscription::getBaseClassIds, TextbookSubscriptionExportQueryListVo::getClassIds)
+                .select("t.student_num + t.teacher_num as subscription_sum")
+                .select(TextbookSubscriptionItem.class, x -> VoToColumnUtil.fieldsToColumns(TextbookSubscriptionExportQueryListVo.class).contains(x.getProperty()))
+                .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookSubscriptionExportQueryListVo.class).contains(x.getProperty()))
+                .leftJoin(TextbookSubscription.class, TextbookSubscription::getId, TextbookSubscriptionItem::getTextbookSubscriptionId)
+                .leftJoin(Textbook.class, Textbook::getId, TextbookSubscriptionItem::getTextbookId)
+                .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
+                        ext -> ext.selectAs(DictionaryDetail::getName, TextbookSubscriptionExportQueryListVo::getTextbookTypeCn))
+                .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, Textbook::getCourseSubjectId)
+                .eq(TextbookSubscriptionItem::getTextbookSubscriptionId, textbookSubscription.getId())
+        ;
+        List<TextbookSubscriptionExportQueryListVo> itemList = textbookSubscriptionTextbookSubscriptionItemMapper.selectJoinList(TextbookSubscriptionExportQueryListVo.class, textbookSubscriptionItemMPJLambdaWrapper);
+
+        //处理班级
+        String classIds = "";
+        List<String> classIdList = new ArrayList<>();
+        StringBuilder sb = new StringBuilder();
+        if (!itemList.isEmpty() && itemList.get(0).getClassIds() != null && !itemList.get(0).getClassIds().equals("")) {
+            classIds = itemList.get(0).getClassIds();
+            String[] classIdArr = classIds.split(",");
+            classIdList = Arrays.asList(classIdArr);
+            /*if(!classIdList.isEmpty()){
+                List<BaseClass> baseClassList = baseClassMapper.selectList(Wrappers.<BaseClass>query().lambda().in(BaseClass::getId, classIdList));
+                Map<Long, BaseClass> baseClassMap = baseClassList.stream()
+                        .collect(Collectors.toMap(BaseClass::getId, baseClass -> baseClass));
+
+                for (String classId : classIdList){
+                    BaseClass baseClass = baseClassMap.get(Long.parseLong(classId));
+                    if(baseClass != null){
+                        sb.append(baseClass.getName());
+                        sb.append(",");
+                    }
+                }
+                sb.deleteCharAt(sb.length() - 1);
+            }*/
+        }
+
+        for (TextbookSubscriptionExportQueryListVo w : itemList) {
+            w.setClassNum(classIdList.size());
+        }
+
+        return itemList;
+    }
 }

+ 79 - 65
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,8 +27,10 @@ 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;
+import org.springframework.util.ObjectUtils;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -57,16 +53,18 @@ 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;
 
+    private final ClaimItemSubscriptionItemMapper claimItemSubscriptionItemMapper;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean add(WfTextbookClaim wfTextbookClaim) {
@@ -213,54 +211,71 @@ 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());
-
+            Textbook textbook = textbookMapper.selectById(textbookClaimItem.getTextbookId());
             if (ObjectUtil.isNull(textbook)) {
                 throw new MyException("未找到相关教材数据");
             }
 
             //判断总发放数量是否超出该申请项的申请数量
             Integer issueNumber = ObjectUtil.isNull(wfTextbookClaimItem.getIssueNumber()) ? 0 : wfTextbookClaimItem.getIssueNumber();//已发放
-            Integer confirmNumber = ObjectUtil.isNull(textbookClaimItem.getConfirmNumber()) ? 0 : textbookClaimItem.getConfirmNumber();//本次发放
             Integer applicantNumber = ObjectUtil.isNull(wfTextbookClaimItem.getApplicantNumber()) ? 0 : wfTextbookClaimItem.getApplicantNumber();//申领总数量
+            Integer confirmNumber = ObjectUtil.isNull(textbookClaimItem.getConfirmTotalNumber()) ? 0 : textbookClaimItem.getConfirmTotalNumber();//本次发放
             if (issueNumber + confirmNumber > applicantNumber) {
                 throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
             }
 
-            //判断发放量是否多于库存量
+            for (ConfirmDistributeDto.TextbookSubscriptionItems textbookSubscriptionItems : textbookClaimItem.getTextbookSubscriptionItems()){
+                TextbookSubscriptionItem textbookSubscriptionItem = textbookSubscriptionItemMapper.selectById(textbookSubscriptionItems.getTextbookSubscriptionItemId());
+                if (ObjectUtils.isEmpty(textbookSubscriptionItem)) {
+                    throw new MyException("未找到征订项详细数据");
+                }
+
+                //更新教材征订中的的库存数量
+                textbookSubscriptionItemMapper.updateById(new TextbookSubscriptionItem() {{
+                    setModifyUserId(StpUtil.getLoginIdAsLong());
+                    setModifyDate(new Date());
+                    setId(textbookSubscriptionItem.getId());
+                    setOutStockNum(ObjectUtil.isNull(textbookSubscriptionItem.getOutStockNum()) ? 0 : textbookSubscriptionItem.getOutStockNum()
+                             + confirmNumber);
+                }});
+
+                claimItemSubscriptionItemMapper.insert(new ClaimItemSubscriptionItem(){{
+                    setWfTextbookClaimItemId(wfTextbookClaimItem.getId());
+                    setTextbookSubscriptionItemId(textbookSubscriptionItem.getId());
+                    setIssueNumber(confirmNumber);
+                }});
+            }
 
             //增加出库记录
-            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() {{
-                setModifyUserId(StpUtil.getLoginIdAsLong());
-                setModifyDate(new Date());
-                setId(textbook.getId());
             }});
 
             //更新申领项中的已经发放数量
@@ -271,35 +286,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;
     }

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

@@ -284,7 +284,7 @@ public class WfTextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<WfText
 
     @Override
     public List<TextbookSubscriptionExportQueryListVo> textbookSubscriptionExportQuery(TextbookSubscriptionExportQueryListDto dto) {
-        WfTextbookSubscription wfTextbookSubscription = this.getById(dto.getWfTextbookSubscriptionId());
+        WfTextbookSubscription wfTextbookSubscription = this.getById(dto.getTextbookSubscriptionId());
         if (wfTextbookSubscription == null) {
             return null;
         }

+ 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 ='退书申请项';
+
+
 
 
 

+ 1 - 1
src/test/java/com/xjrsoft/module/liteflow/node/StudentDropOutNodeTest.java

@@ -61,7 +61,7 @@ class StudentDropOutNodeTest {
     void test(){
         Long formId = 1863523681699409920L;
         // 获取表单中数据编号
-        Object processInstanceId = "4af1e5f0-b094-11ef-9e41-0242c8000007";
+        Object processInstanceId = "ee72acf7-b6a0-11ef-9921-0242c8000007";
         String processInstanceIdStr = Convert.toStr(processInstanceId);
         if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
             TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {

+ 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());
+    }
+
 }