فهرست منبع

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

dzx 5 ماه پیش
والد
کامیت
40bc314974

+ 54 - 0
src/main/java/com/xjrsoft/common/enums/UseSemesterTypeEnum.java

@@ -0,0 +1,54 @@
+package com.xjrsoft.common.enums;
+
+public enum UseSemesterTypeEnum {
+    /**
+     * 周一
+     */
+    SEMESTER_ONE(1, "一学期"),
+
+    /**
+     * 周二
+     */
+    SEMESTER_TWO(2, "二学期"),
+    /**
+     * 周三
+     */
+    SEMESTER_THREE(3, "三学期"),
+    /**
+     * 周四
+     */
+    SEMESTER_FOUR(4, "四学期"),
+    /**
+     * 周五
+     */
+    SEMESTER_FIVE(5, "五学期"),
+    /**
+     * 周六
+     */
+    SEMESTER_SIX(6, "六学期");
+
+    final int code;
+    final String value;
+
+    public int getCode() {
+        return this.code;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+
+    UseSemesterTypeEnum(final int code, final String message) {
+        this.code = code;
+        this.value = message;
+    }
+
+    public static int getCode(String value) {
+        for (UseSemesterTypeEnum c : UseSemesterTypeEnum.values()) {
+            if (c.getValue().equals(value)) {
+                return c.getCode();
+            }
+        }
+        return 0;
+    }
+}

+ 12 - 0
src/main/java/com/xjrsoft/module/textbook/controller/WfTextbookSubscriptionController.java

@@ -6,6 +6,7 @@ import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.support.ExcelTypeEnum;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.model.result.R;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
@@ -28,9 +29,12 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.*;
 
 /**
@@ -257,4 +261,12 @@ public class WfTextbookSubscriptionController {
 
         return RT.fileStream(bot.toByteArray(), "TextbookSubscription" + ExcelTypeEnum.XLSX.getValue());
     }
+
+    @PostMapping("/instockroom-excel-import")
+    @ApiOperation(value = "教材征订入库数量导入")
+    @SaCheckPermission("coursetable:excelimport")
+    public R excelImport(@RequestParam("file") MultipartFile file) throws IOException {
+        InputStream inputStream = file.getInputStream();
+        return R.ok(wfTextbookSubscriptionService.excelImport(inputStream));
+    }
 }

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

@@ -57,7 +57,7 @@ public class TextbookImportDto {
     @ContentStyle(dataFormat = 49)
     @ExcelProperty("使用类型(一学期~六学期)")
     @ApiModelProperty("使用类型(单位:学期)")
-    private Integer useType;
+    private String useTypeCn;
     /**
      * 教材类型(xjr_dictionary_item[textbook_type])
      */

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

@@ -7,6 +7,7 @@ import com.xjrsoft.module.textbook.vo.TextbookInstockroomListVo;
 import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
 import com.xjrsoft.module.textbook.vo.WfTextbookSubscriptionVo;
 
+import java.io.InputStream;
 import java.util.List;
 
 /**
@@ -53,4 +54,7 @@ public interface IWfTextbookSubscriptionService extends MPJBaseService<WfTextboo
     List<TextbookInstockroomListVo> instockroomList(TextbookInstockroomListDto dto);
 
     Boolean instockroom(List<TextbookInstockroomDto> dtos);
+
+
+    Boolean excelImport(InputStream inputStream);
 }

+ 21 - 2
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.textbook.service.impl;
 
+import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
@@ -20,6 +21,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.ExerciseBookeTypeEnum;
 import com.xjrsoft.common.enums.TextbookTypeEnum;
+import com.xjrsoft.common.enums.UseSemesterTypeEnum;
 import com.xjrsoft.common.enums.WarehouseModeEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.utils.excel.ExcelFillCellMergePrevColUtil;
@@ -32,6 +34,7 @@ import com.xjrsoft.module.base.mapper.BaseCourseSubjectMapper;
 import com.xjrsoft.module.base.mapper.BaseGradeMapper;
 import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
 import com.xjrsoft.module.base.service.IBaseClassService;
+import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.textbook.dto.AddTextbookWarehouseRecordDto;
 import com.xjrsoft.module.textbook.dto.TextbookClaimExportQueryDto;
@@ -841,7 +844,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                 throw new MyException("导入数据为空");
             }
             saveData(dataList);
-        })).sheet().doRead();
+        })).sheet().headRowNumber(3).doRead();
 
         return true;
     }
@@ -893,6 +896,9 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     .orElse(null);
             textbook.setTextbookType(textbookTypeCode);
 
+            //处理使用类型
+            textbook.setUseType(UseSemesterTypeEnum.getCode(textbookImportDto.getUseTypeCn()));
+
             // 判断导入的教材是否已经存在,根据教材的 ISBN 码和使用的学期判断
             LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
             textbookLambdaQueryWrapper
@@ -901,16 +907,29 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
 
             Textbook oldTextbook = this.getOne(textbookLambdaQueryWrapper);
 
+            Date now = new Date();
+            Long loginId = StpUtil.getLoginIdAsLong();
             // 已经存在,更新数据
             if (oldTextbook != null) {
                 // 更新教材数据
+                textbookCoreAttribute.setId(oldTextbook.getTextbookCoreAttributeId());
+                textbookCoreAttribute.setModifyDate(now);
+                textbookCoreAttribute.setModifyUserId(loginId);
+                textbookCoreAttributeService.updateById(textbookCoreAttribute);
+
                 textbook.setId(oldTextbook.getId());
+                textbook.setModifyDate(now);
+                textbook.setModifyUserId(loginId);
                 textbookTextbookMapper.updateById(textbook);
             } else {
+                textbookCoreAttribute.setCreateDate(now);
+                textbookCoreAttribute.setCreateUserId(loginId);
                 textbookCoreAttributeService.save(textbookCoreAttribute);
 
-                textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
                 // 插入教材数据
+                textbook.setCreateDate(now);
+                textbook.setCreateUserId(loginId);
+                textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
                 textbookTextbookMapper.insert(textbook);
             }
         }

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

@@ -2,11 +2,15 @@ package com.xjrsoft.module.textbook.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.read.listener.PageReadListener;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.TextbookTypeEnum;
+import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseCourseSubject;
@@ -29,6 +33,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.InputStream;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -374,4 +379,86 @@ public class WfTextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<WfText
         }
         return true;
     }
+
+    @Override
+    public Boolean excelImport(InputStream inputStream) {
+        EasyExcel.read(inputStream, TextbookImportDto.class, new PageReadListener<TextbookImportDto>(dataList -> {
+            if (dataList.isEmpty()) {
+                throw new MyException("导入数据为空");
+            }
+            saveData(dataList);
+        })).sheet().headRowNumber(3).doRead();
+
+        return true;
+    }
+
+    private void saveData(List<TextbookImportDto> dataList) {
+        /*//查询所有需要的数据
+        //学科组
+        List<SubjectGroup> subjectGroupList = subjectGroupMapper.selectList(new LambdaQueryWrapper<>());
+        Map<String, Long> subjectGroupNameAndIdMap = subjectGroupList.stream().collect(Collectors.toMap(SubjectGroup::getGroupName, SubjectGroup::getId, (k1, k2) -> k1));
+
+        //使用课程
+        List<BaseCourseSubject> baseCourseSubjectList = baseCourseSubjectMapper.selectList(new LambdaQueryWrapper<>());
+        Map<String, Long> baseCourseSubjectNameAndIdMap = baseCourseSubjectList.stream().collect(Collectors.toMap(BaseCourseSubject::getName, BaseCourseSubject::getId, (k1, k2) -> k1));
+
+        //批量插入或更新数据
+        for (TextbookImportDto textbookImportDto : dataList) {
+            TextbookCoreAttribute textbookCoreAttribute = new TextbookCoreAttribute();
+            BeanUtils.copyProperties(textbookImportDto, textbookCoreAttribute);
+
+            Textbook textbook = new Textbook();
+            BeanUtils.copyProperties(textbookImportDto, textbook);
+
+            // 处理学科组映射
+            String groupName = textbookImportDto.getGroupName();
+            Long subjectGroupId = Optional.ofNullable(groupName)
+                    .map(subjectGroupNameAndIdMap::get)
+                    .orElse(null);
+            textbook.setSubjectGroupId(subjectGroupId);
+
+            // 处理课程映射
+            String courseName = textbookImportDto.getCourseName();
+            Long courseSubjectId = Optional.ofNullable(courseName)
+                    .map(baseCourseSubjectNameAndIdMap::get)
+                    .orElse(null);
+            textbook.setCourseSubjectId(courseSubjectId);
+
+            // 处理是否教材计划字段
+            String isTextbookPlanCn = textbookImportDto.getIsTextbookPlanCn();
+            String isTextbookPlan = Optional.ofNullable(isTextbookPlanCn)
+                    .filter("是"::equals)
+                    .map(s -> "yes")
+                    .orElse("no");
+            textbook.setIsTextbookPlan(isTextbookPlan);
+
+            // 处理教材类型映射
+            String textbookTypeCn = textbookImportDto.getTextbookTypeCn();
+            String textbookTypeCode = Optional.ofNullable(textbookTypeCn)
+                    .map(TextbookTypeEnum::getCode)
+                    .orElse(null);
+            textbook.setTextbookType(textbookTypeCode);
+
+            // 判断导入的教材是否已经存在,根据教材的 ISBN 码和使用的学期判断
+            LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            textbookLambdaQueryWrapper
+                    .eq(Textbook::getIssn, textbook.getIssn())
+            ;
+
+            Textbook oldTextbook = this.getOne(textbookLambdaQueryWrapper);
+
+            // 已经存在,更新数据
+            if (oldTextbook != null) {
+                // 更新教材数据
+                textbook.setId(oldTextbook.getId());
+                textbookTextbookMapper.updateById(textbook);
+            } else {
+                textbookCoreAttributeService.save(textbookCoreAttribute);
+
+                textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
+                // 插入教材数据
+                textbookTextbookMapper.insert(textbook);
+            }
+        }*/
+    }
 }

+ 7 - 22
src/main/java/com/xjrsoft/module/textbook/vo/TextbookStandingExportQueryVo.java

@@ -44,6 +44,13 @@ public class TextbookStandingExportQueryVo {
     @ExcelProperty("主编")
     @ApiModelProperty("主编")
     private String editorInChief;
+    /**
+     * 版本
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("版次")
+    @ApiModelProperty("版本")
+    private String version;
     /**
      * 学科组名称
      */
@@ -51,27 +58,6 @@ public class TextbookStandingExportQueryVo {
     @ExcelProperty("学科组名称")
     @ApiModelProperty("学科组名称")
     private String groupName;
-    /**
-     * 使用年级
-     */
-    @ContentStyle(dataFormat = 49)
-    @ExcelProperty("使用年级")
-    @ApiModelProperty("使用年级")
-    private String useGrade;
-    /**
-     * 使用年级
-     */
-    @ContentStyle(dataFormat = 49)
-    @ExcelProperty("使用学期")
-    @ApiModelProperty("使用学期")
-    private String semesterCn;
-    /**
-     * 使用班级
-     */
-    @ContentStyle(dataFormat = 49)
-    @ExcelProperty("使用班级")
-    @ApiModelProperty("使用班级")
-    private String useClass;
     /**
     * 课程
     */
@@ -86,7 +72,6 @@ public class TextbookStandingExportQueryVo {
     @ExcelProperty("是否为规划教材")
     @ApiModelProperty("是否为规划教材")
     private String isTextbookPlanCn;
-
     /**
      * 教材类型(xjr_dictionary_item[textbook_type])
      */

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环境 dev|pre|prod
   profiles:
-    active: dev
+    active: pre
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 2 - 7
src/main/resources/mapper/textbook/TextbookMapper.xml

@@ -157,12 +157,8 @@
         t1.book_name,
         t1.publishing_house,
         t1.editor_in_chief,
+        t1.version,
         t2.group_name,
-        t6.name AS use_grade,
-        (SELECT GROUP_CONCAT(c2.name)
-        FROM textbook_class_relation c1
-        LEFT JOIN base_class c2 ON c1.class_id = c2.id
-        WHERE c1.textbook_id = t1.id) AS use_class,
         t4.name AS course_name,
         t7.name AS is_textbook_plan_cn,
         t5.name AS textbook_type_cn,
@@ -171,8 +167,7 @@
         t1.price,
         t1.discount,
         t1.subtotal,
-        t1.stock,
-        t8.name as use_semester
+        t1.stock
         FROM textbook t1
         LEFT JOIN subject_group t2 ON t1.subject_group_id = t2.id
         LEFT JOIN base_course_subject t4 ON t1.course_subject_id = t4.id