|
@@ -1,5 +1,6 @@
|
|
|
package com.xjrsoft.module.textbook.service.impl;
|
|
package com.xjrsoft.module.textbook.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -20,6 +21,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.enums.ExerciseBookeTypeEnum;
|
|
import com.xjrsoft.common.enums.ExerciseBookeTypeEnum;
|
|
|
import com.xjrsoft.common.enums.TextbookTypeEnum;
|
|
import com.xjrsoft.common.enums.TextbookTypeEnum;
|
|
|
|
|
+import com.xjrsoft.common.enums.UseSemesterTypeEnum;
|
|
|
import com.xjrsoft.common.enums.WarehouseModeEnum;
|
|
import com.xjrsoft.common.enums.WarehouseModeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.excel.ExcelFillCellMergePrevColUtil;
|
|
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.BaseGradeMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
|
|
import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
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.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.textbook.dto.AddTextbookWarehouseRecordDto;
|
|
import com.xjrsoft.module.textbook.dto.AddTextbookWarehouseRecordDto;
|
|
|
import com.xjrsoft.module.textbook.dto.TextbookClaimExportQueryDto;
|
|
import com.xjrsoft.module.textbook.dto.TextbookClaimExportQueryDto;
|
|
@@ -841,7 +844,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
throw new MyException("导入数据为空");
|
|
throw new MyException("导入数据为空");
|
|
|
}
|
|
}
|
|
|
saveData(dataList);
|
|
saveData(dataList);
|
|
|
- })).sheet().doRead();
|
|
|
|
|
|
|
+ })).sheet().headRowNumber(3).doRead();
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -852,22 +855,10 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
List<SubjectGroup> subjectGroupList = subjectGroupMapper.selectList(new LambdaQueryWrapper<>());
|
|
List<SubjectGroup> subjectGroupList = subjectGroupMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
Map<String, Long> subjectGroupNameAndIdMap = subjectGroupList.stream().collect(Collectors.toMap(SubjectGroup::getGroupName, SubjectGroup::getId, (k1, k2) -> k1));
|
|
Map<String, Long> subjectGroupNameAndIdMap = subjectGroupList.stream().collect(Collectors.toMap(SubjectGroup::getGroupName, SubjectGroup::getId, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
- //使用年级
|
|
|
|
|
- List<BaseGrade> baseGradeList = baseGradeMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
|
|
- Map<String, Long> baseGradeNameAndIdMap = baseGradeList.stream().collect(Collectors.toMap(BaseGrade::getName, BaseGrade::getId, (k1, k2) -> k1));
|
|
|
|
|
-
|
|
|
|
|
- //使用班级
|
|
|
|
|
- List<BaseClass> baseClassList = baseClassService.list();
|
|
|
|
|
- Map<String, Long> baseClassNameAndIdMap = baseClassList.stream().collect(Collectors.toMap(BaseClass::getName, BaseClass::getId, (k1, k2) -> k1));
|
|
|
|
|
-
|
|
|
|
|
//使用课程
|
|
//使用课程
|
|
|
List<BaseCourseSubject> baseCourseSubjectList = baseCourseSubjectMapper.selectList(new LambdaQueryWrapper<>());
|
|
List<BaseCourseSubject> baseCourseSubjectList = baseCourseSubjectMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
Map<String, Long> baseCourseSubjectNameAndIdMap = baseCourseSubjectList.stream().collect(Collectors.toMap(BaseCourseSubject::getName, BaseCourseSubject::getId, (k1, k2) -> k1));
|
|
Map<String, Long> baseCourseSubjectNameAndIdMap = baseCourseSubjectList.stream().collect(Collectors.toMap(BaseCourseSubject::getName, BaseCourseSubject::getId, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
- //使用学期
|
|
|
|
|
- List<BaseSemester> baseSemesterList = baseSemesterMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
|
|
- Map<String, Long> baseSemesterNameAndIdMap = baseSemesterList.stream().collect(Collectors.toMap(BaseSemester::getName, BaseSemester::getId, (k1, k2) -> k1));
|
|
|
|
|
-
|
|
|
|
|
//批量插入或更新数据
|
|
//批量插入或更新数据
|
|
|
for (TextbookImportDto textbookImportDto : dataList) {
|
|
for (TextbookImportDto textbookImportDto : dataList) {
|
|
|
TextbookCoreAttribute textbookCoreAttribute = new TextbookCoreAttribute();
|
|
TextbookCoreAttribute textbookCoreAttribute = new TextbookCoreAttribute();
|
|
@@ -890,13 +881,6 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
.orElse(null);
|
|
.orElse(null);
|
|
|
textbook.setCourseSubjectId(courseSubjectId);
|
|
textbook.setCourseSubjectId(courseSubjectId);
|
|
|
|
|
|
|
|
- // 处理年级映射
|
|
|
|
|
- String useGrade = textbookImportDto.getUseGrade();
|
|
|
|
|
- Long gradeId = Optional.ofNullable(useGrade)
|
|
|
|
|
- .map(baseGradeNameAndIdMap::get)
|
|
|
|
|
- .orElse(null);
|
|
|
|
|
- textbook.setGradeId(gradeId);
|
|
|
|
|
-
|
|
|
|
|
// 处理是否教材计划字段
|
|
// 处理是否教材计划字段
|
|
|
String isTextbookPlanCn = textbookImportDto.getIsTextbookPlanCn();
|
|
String isTextbookPlanCn = textbookImportDto.getIsTextbookPlanCn();
|
|
|
String isTextbookPlan = Optional.ofNullable(isTextbookPlanCn)
|
|
String isTextbookPlan = Optional.ofNullable(isTextbookPlanCn)
|
|
@@ -912,69 +896,41 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
.orElse(null);
|
|
.orElse(null);
|
|
|
textbook.setTextbookType(textbookTypeCode);
|
|
textbook.setTextbookType(textbookTypeCode);
|
|
|
|
|
|
|
|
- // 处理学期映射
|
|
|
|
|
- String useSemester = textbookImportDto.getUseSemester();
|
|
|
|
|
- Long baseSemesterId = Optional.ofNullable(useSemester)
|
|
|
|
|
- .map(baseSemesterNameAndIdMap::get)
|
|
|
|
|
- .orElse(null);
|
|
|
|
|
- textbook.setBaseSemesterId(baseSemesterId);
|
|
|
|
|
-
|
|
|
|
|
- // 处理班级映射
|
|
|
|
|
- List<Long> classIdList = Optional.ofNullable(textbookImportDto.getUseClass())
|
|
|
|
|
- .map(classNames -> Arrays.stream(classNames.split(","))
|
|
|
|
|
- .map(String::trim)
|
|
|
|
|
- .map(baseClassNameAndIdMap::get)
|
|
|
|
|
- .filter(Objects::nonNull)
|
|
|
|
|
- .collect(Collectors.toList()))
|
|
|
|
|
- .orElse(Collections.emptyList());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //处理使用类型
|
|
|
|
|
+ textbook.setUseType(UseSemesterTypeEnum.getCode(textbookImportDto.getUseTypeCn()));
|
|
|
|
|
|
|
|
// 判断导入的教材是否已经存在,根据教材的 ISBN 码和使用的学期判断
|
|
// 判断导入的教材是否已经存在,根据教材的 ISBN 码和使用的学期判断
|
|
|
LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
textbookLambdaQueryWrapper
|
|
textbookLambdaQueryWrapper
|
|
|
.eq(Textbook::getIssn, textbook.getIssn())
|
|
.eq(Textbook::getIssn, textbook.getIssn())
|
|
|
- .eq(Textbook::getBaseSemesterId, textbook.getBaseSemesterId())
|
|
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
Textbook oldTextbook = this.getOne(textbookLambdaQueryWrapper);
|
|
Textbook oldTextbook = this.getOne(textbookLambdaQueryWrapper);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ Long loginId = StpUtil.getLoginIdAsLong();
|
|
|
// 已经存在,更新数据
|
|
// 已经存在,更新数据
|
|
|
if (oldTextbook != null) {
|
|
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);
|
|
textbookTextbookMapper.updateById(textbook);
|
|
|
-
|
|
|
|
|
- // 先删除使用班级的信息,再新增
|
|
|
|
|
- LambdaQueryWrapper<TextbookClassRelation> textbookClassRelationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- textbookClassRelationLambdaQueryWrapper
|
|
|
|
|
- .eq(TextbookClassRelation::getTextbookId, textbook.getId());
|
|
|
|
|
-
|
|
|
|
|
- textbookTextbookClassRelationMapper.delete(textbookClassRelationLambdaQueryWrapper);
|
|
|
|
|
-
|
|
|
|
|
- // 批量插入班级关系
|
|
|
|
|
- for (Long classId : classIdList) {
|
|
|
|
|
- textbookTextbookClassRelationMapper.insert(new TextbookClassRelation() {{
|
|
|
|
|
- setCreateDate(new Date());
|
|
|
|
|
- setTextbookId(textbook.getId());
|
|
|
|
|
- setClassId(classId);
|
|
|
|
|
- }});
|
|
|
|
|
- }
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ textbookCoreAttribute.setCreateDate(now);
|
|
|
|
|
+ textbookCoreAttribute.setCreateUserId(loginId);
|
|
|
textbookCoreAttributeService.save(textbookCoreAttribute);
|
|
textbookCoreAttributeService.save(textbookCoreAttribute);
|
|
|
|
|
|
|
|
- textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
|
|
|
|
|
// 插入教材数据
|
|
// 插入教材数据
|
|
|
|
|
+ textbook.setCreateDate(now);
|
|
|
|
|
+ textbook.setCreateUserId(loginId);
|
|
|
|
|
+ textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
|
|
|
textbookTextbookMapper.insert(textbook);
|
|
textbookTextbookMapper.insert(textbook);
|
|
|
-
|
|
|
|
|
- //插入班级和教材关系
|
|
|
|
|
- for (Long classId : classIdList) {
|
|
|
|
|
- textbookTextbookClassRelationMapper.insert(new TextbookClassRelation() {{
|
|
|
|
|
- setCreateDate(new Date());
|
|
|
|
|
- setTextbookId(textbook.getId());
|
|
|
|
|
- setClassId(classId);
|
|
|
|
|
- }});
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|