|
@@ -1,12 +1,9 @@
|
|
|
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;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
-import com.alibaba.excel.read.listener.PageReadListener;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
import com.alibaba.excel.write.metadata.WriteTable;
|
|
@@ -16,13 +13,14 @@ import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
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.*;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.common.utils.excel.ExcelFillCellMergePrevColUtil;
|
|
|
import com.xjrsoft.common.utils.excel.ExcelMergeUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
@@ -30,29 +28,28 @@ import com.xjrsoft.module.base.entity.BaseClassCourse;
|
|
|
import com.xjrsoft.module.base.entity.BaseCourseSubject;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
|
|
|
-import com.xjrsoft.module.base.mapper.BaseCourseSubjectMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.textbook.dto.*;
|
|
|
import com.xjrsoft.module.textbook.entity.*;
|
|
|
import com.xjrsoft.module.textbook.mapper.*;
|
|
|
-import com.xjrsoft.module.textbook.service.ITextbookCoreAttributeService;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookService;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookWarehouseRecordService;
|
|
|
import com.xjrsoft.module.textbook.service.IWfExerciseBookService;
|
|
|
import com.xjrsoft.module.textbook.vo.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -82,143 +79,170 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
|
|
|
private final TextbookStudentClaimMapper textbookStudentClaimMapper;
|
|
|
|
|
|
- private final SubjectGroupMapper subjectGroupMapper;
|
|
|
-
|
|
|
private final BaseSemesterMapper baseSemesterMapper;
|
|
|
|
|
|
- private final BaseCourseSubjectMapper baseCourseSubjectMapper;
|
|
|
-
|
|
|
- private final ITextbookCoreAttributeService textbookCoreAttributeService;
|
|
|
-
|
|
|
- private final TextbookCoreAttributeMapper textbookCoreAttributeMapper;
|
|
|
-
|
|
|
private final BaseClassCourseMapper baseClassCourseMapper;
|
|
|
|
|
|
+ private final TextbookSubscriptionItemMapper textbookSubscriptionItemMapper;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean add(Textbook textbook) {
|
|
|
- textbook.setCreateDate(new Date());
|
|
|
- TextbookCoreAttribute textbookCoreAttribute = new TextbookCoreAttribute();
|
|
|
- BeanUtils.copyProperties(textbook, textbookCoreAttribute);
|
|
|
- textbookCoreAttributeMapper.insert(textbookCoreAttribute);
|
|
|
- textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
|
|
|
- textbook.setSubtotal(textbook.getPrice().multiply(BigDecimal.valueOf(textbook.getDiscount()/10)));
|
|
|
- textbookTextbookMapper.insert(textbook);
|
|
|
- for (TextbookClassRelation textbookClassRelation : textbook.getTextbookClassRelationList()) {
|
|
|
- textbookClassRelation.setTextbookId(textbook.getId());
|
|
|
- textbookClassRelation.setCreateDate(new Date());
|
|
|
- textbookTextbookClassRelationMapper.insert(textbookClassRelation);
|
|
|
+ public Boolean addRubAndHand(Textbook textbook) {
|
|
|
+ // 判断isbn的唯一性
|
|
|
+ if(StringUtils.isBlank(textbook.getIssn())
|
|
|
+ || ObjectUtils.isEmpty(textbook.getSubjectGroupId())
|
|
|
+ || ObjectUtils.isEmpty(textbook.getCourseSubjectId()) ){
|
|
|
+ throw new MyException("issn,学科组,课程为必填字段");
|
|
|
}
|
|
|
- if (textbook.getTextbookSubscriptionRecordList() != null) {
|
|
|
- for (TextbookSubscriptionRecord textbookSubscriptionRecord : textbook.getTextbookSubscriptionRecordList()) {
|
|
|
- textbookSubscriptionRecord.setTextbookId(textbook.getId());
|
|
|
- textbookSubscriptionRecord.setCreateDate(new Date());
|
|
|
- textbookTextbookSubscriptionRecordMapper.insert(textbookSubscriptionRecord);
|
|
|
- }
|
|
|
+
|
|
|
+ // 判断导入的教材是否已经存在,根据教材的 ISSN 码和使用的学科组和课程判断
|
|
|
+ LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ textbookLambdaQueryWrapper
|
|
|
+ .eq(Textbook::getIssn, textbook.getIssn())
|
|
|
+ .eq(Textbook::getSubjectGroupId, textbook.getSubjectGroupId())
|
|
|
+ .eq(Textbook::getCourseSubjectId, textbook.getCourseSubjectId())
|
|
|
+ .eq(Textbook::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+
|
|
|
+ Textbook verifyTextbook = textbookTextbookMapper.selectOne(textbookLambdaQueryWrapper);
|
|
|
+ int num;
|
|
|
+ if(ObjectUtils.isNotEmpty(verifyTextbook)){
|
|
|
+ textbook.setId(verifyTextbook.getId());
|
|
|
+ num = textbookTextbookMapper.updateById(textbook);
|
|
|
+ }else {
|
|
|
+ num = textbookTextbookMapper.insert(textbook);
|
|
|
}
|
|
|
- return true;
|
|
|
+ return num > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean update(Textbook textbook) {
|
|
|
- textbookTextbookMapper.updateById(textbook);
|
|
|
- //********************************* TextbookClassRelation 增删改 开始 *******************************************/
|
|
|
- {
|
|
|
- // 查出所有子级的id
|
|
|
- List<TextbookClassRelation> textbookClassRelationList = textbookTextbookClassRelationMapper.selectList(Wrappers.lambdaQuery(TextbookClassRelation.class).eq(TextbookClassRelation::getTextbookId, textbook.getId()).select(TextbookClassRelation::getId));
|
|
|
- List<Long> textbookClassRelationIds = textbookClassRelationList.stream().map(TextbookClassRelation::getId).collect(Collectors.toList());
|
|
|
- //原有子表单 没有被删除的主键
|
|
|
- List<Long> textbookClassRelationOldIds = textbook.getTextbookClassRelationList().stream().map(TextbookClassRelation::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- //找到需要删除的id
|
|
|
- List<Long> textbookClassRelationRemoveIds = textbookClassRelationIds.stream().filter(item -> !textbookClassRelationOldIds.contains(item)).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (TextbookClassRelation textbookClassRelation : textbook.getTextbookClassRelationList()) {
|
|
|
- //如果不等于空则修改
|
|
|
- if (textbookClassRelation.getId() != null) {
|
|
|
- textbookTextbookClassRelationMapper.updateById(textbookClassRelation);
|
|
|
- }
|
|
|
- //如果等于空 则新增
|
|
|
- else {
|
|
|
- //已经不存在的id 删除
|
|
|
- textbookClassRelation.setTextbookId(textbook.getId());
|
|
|
- textbookTextbookClassRelationMapper.insert(textbookClassRelation);
|
|
|
- }
|
|
|
- }
|
|
|
- //已经不存在的id 删除
|
|
|
- if (textbookClassRelationRemoveIds.size() > 0) {
|
|
|
- textbookTextbookClassRelationMapper.deleteBatchIds(textbookClassRelationRemoveIds);
|
|
|
- }
|
|
|
- }
|
|
|
- //********************************* TextbookClassRelation 增删改 结束 *******************************************/
|
|
|
-
|
|
|
- //********************************* TextbookSubscriptionRecord 增删改 开始 *******************************************/
|
|
|
- {
|
|
|
- // 查出所有子级的id
|
|
|
- List<TextbookSubscriptionRecord> textbookSubscriptionRecordList = textbookTextbookSubscriptionRecordMapper.selectList(Wrappers.lambdaQuery(TextbookSubscriptionRecord.class).eq(TextbookSubscriptionRecord::getWfTextbookSubscriptionId, textbook.getId()).select(TextbookSubscriptionRecord::getId));
|
|
|
- List<Long> textbookSubscriptionRecordIds = textbookSubscriptionRecordList.stream().map(TextbookSubscriptionRecord::getId).collect(Collectors.toList());
|
|
|
- //原有子表单 没有被删除的主键
|
|
|
- if (!textbookSubscriptionRecordIds.isEmpty()) {
|
|
|
- List<Long> textbookSubscriptionRecordOldIds = textbook.getTextbookSubscriptionRecordList().stream().map(TextbookSubscriptionRecord::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- //找到需要删除的id
|
|
|
- List<Long> textbookSubscriptionRecordRemoveIds = textbookSubscriptionRecordIds.stream().filter(item -> !textbookSubscriptionRecordOldIds.contains(item)).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (TextbookSubscriptionRecord textbookSubscriptionRecord : textbook.getTextbookSubscriptionRecordList()) {
|
|
|
- //如果不等于空则修改
|
|
|
- if (textbookSubscriptionRecord.getId() != null) {
|
|
|
- textbookTextbookSubscriptionRecordMapper.updateById(textbookSubscriptionRecord);
|
|
|
- }
|
|
|
- //如果等于空 则新增
|
|
|
- else {
|
|
|
- //已经不存在的id 删除
|
|
|
- textbookSubscriptionRecord.setWfTextbookSubscriptionId(textbook.getId());
|
|
|
- textbookTextbookSubscriptionRecordMapper.insert(textbookSubscriptionRecord);
|
|
|
- }
|
|
|
- }
|
|
|
- //已经不存在的id 删除
|
|
|
- if (textbookSubscriptionRecordRemoveIds.size() > 0) {
|
|
|
- textbookTextbookSubscriptionRecordMapper.deleteBatchIds(textbookSubscriptionRecordRemoveIds);
|
|
|
- }
|
|
|
- for (TextbookSubscriptionRecord textbookSubscriptionRecord : textbook.getTextbookSubscriptionRecordList()) {
|
|
|
- //如果不等于空则修改
|
|
|
- if (textbookSubscriptionRecord.getId() != null) {
|
|
|
- textbookTextbookSubscriptionRecordMapper.updateById(textbookSubscriptionRecord);
|
|
|
- }
|
|
|
- //如果等于空 则新增
|
|
|
- else {
|
|
|
- //已经不存在的id 删除
|
|
|
- textbookSubscriptionRecord.setWfTextbookSubscriptionId(textbook.getId());
|
|
|
- textbookTextbookSubscriptionRecordMapper.insert(textbookSubscriptionRecord);
|
|
|
- }
|
|
|
- }
|
|
|
- //已经不存在的id 删除
|
|
|
- if (textbookSubscriptionRecordRemoveIds.size() > 0) {
|
|
|
- textbookTextbookSubscriptionRecordMapper.deleteBatchIds(textbookSubscriptionRecordRemoveIds);
|
|
|
- }
|
|
|
+ public Boolean updateRubAndHand(Textbook textbook) {
|
|
|
+ int num = textbookTextbookMapper.updateById(textbook);
|
|
|
+ return num > 0;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean delete(List<Long> ids) {
|
|
|
+ // 删除教材前应判断教材是否被班级课程使用,一旦被使用不能删除
|
|
|
+ MPJLambdaWrapper<Textbook> baseClassCourse = new MPJLambdaWrapper<>();
|
|
|
+ baseClassCourse
|
|
|
+ .select(Textbook::getId)
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(Textbook.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(BaseClassCourse.class, BaseClassCourse::getTextbookId, Textbook::getId)
|
|
|
+ .in(Textbook::getId, ids)
|
|
|
+ ;
|
|
|
+ List<Textbook> baseClassCourseTextbooks = this.selectJoinList(Textbook.class, baseClassCourse);
|
|
|
|
|
|
- }
|
|
|
- //********************************* TextbookSubscriptionRecord 增删改 结束 *******************************************/
|
|
|
+ if(!baseClassCourseTextbooks.isEmpty()){
|
|
|
+ throw new MyException(baseClassCourseTextbooks.get(0).getBookName() + "教材在课程中被使用,请先从课程中移除!");
|
|
|
+ }
|
|
|
|
|
|
- return true;
|
|
|
+ // 删除教材前应判断教材是否存在教材征订记录,如果存在征订记录,不应该删除
|
|
|
+ MPJLambdaWrapper<Textbook> textbookSubscriptionItem = new MPJLambdaWrapper<>();
|
|
|
+ textbookSubscriptionItem
|
|
|
+ .select(Textbook::getId)
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(Textbook.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(TextbookSubscriptionItem.class, TextbookSubscriptionItem::getTextbookId, Textbook::getId)
|
|
|
+ .in(Textbook::getId, ids)
|
|
|
+ ;
|
|
|
+ List<Textbook> textbookSubscriptionItemTextbooks = this.selectJoinList(Textbook.class, textbookSubscriptionItem);
|
|
|
+
|
|
|
+ if(!textbookSubscriptionItemTextbooks.isEmpty()){
|
|
|
+ throw new MyException(textbookSubscriptionItemTextbooks.get(0).getBookName() + "教材在证订中被使用,请先从证订中移除!");
|
|
|
}
|
|
|
+
|
|
|
+ textbookTextbookMapper.deleteBatchIds(ids);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean delete(List<Long> ids) {
|
|
|
- textbookTextbookMapper.deleteBatchIds(ids);
|
|
|
- textbookTextbookClassRelationMapper.delete(Wrappers.lambdaQuery(TextbookClassRelation.class).in(TextbookClassRelation::getTextbookId, ids));
|
|
|
- textbookTextbookSubscriptionRecordMapper.delete(Wrappers.lambdaQuery(TextbookSubscriptionRecord.class).in(TextbookSubscriptionRecord::getWfTextbookSubscriptionId, ids));
|
|
|
+ public IPage<TextbookPageVo> pageRubAndHand(TextbookPageDto dto) {
|
|
|
+ MPJLambdaWrapper<Textbook> textbookMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ textbookMPJLambdaWrapper
|
|
|
+ .select(Textbook::getId)
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookPageVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(SubjectGroup.class, SubjectGroup::getId, Textbook::getSubjectGroupId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(SubjectGroup::getGroupName, TextbookPageVo::getGroupName)
|
|
|
+ .like(StringUtils.isNotBlank(dto.getGroupName()), SubjectGroup::getGroupName, dto.getGroupName())
|
|
|
+ )
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, Textbook::getCourseSubjectId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(BaseCourseSubject::getName, TextbookPageVo::getCourseName)
|
|
|
+ .like(StringUtils.isNotBlank(dto.getCourseName()), BaseCourseSubject::getName, dto.getCourseName())
|
|
|
+ )
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, TextbookPageVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getUseType()), Textbook::getUseType, dto.getUseType())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getIssn()), Textbook::getIssn, dto.getIssn())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getIsbn()), Textbook::getIsbn, dto.getIsbn())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getBookName()), Textbook::getBookName, dto.getBookName())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getPublishingHouse()), Textbook::getPublishingHouse, dto.getPublishingHouse())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getEditorInChief()), Textbook::getEditorInChief, dto.getEditorInChief())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getVersion()), Textbook::getVersion, dto.getVersion())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getIsTextbookPlan()), Textbook::getIsTextbookPlan, dto.getIsTextbookPlan())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getTextbookType()), Textbook::getTextbookType, dto.getTextbookType())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getSpecificationsModels()), Textbook::getSpecificationsModels, dto.getSpecificationsModels())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getIsSecd()), Textbook::getIsSecd, dto.getIsSecd())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getCategory()), Textbook::getCategory, dto.getCategory())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getPlanBatch()), Textbook::getPlanBatch, dto.getPlanBatch())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getWorkTotalCount()), Textbook::getWorkTotalCount, dto.getWorkTotalCount())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getTextbookCategory()), Textbook::getTextbookCategory, dto.getTextbookCategory())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getPrice()), Textbook::getPrice, dto.getPrice())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getDiscount()), Textbook::getDiscount, dto.getDiscount())
|
|
|
+ .orderByDesc(Textbook::getId)
|
|
|
+ ;
|
|
|
|
|
|
- return true;
|
|
|
+ return textbookTextbookMapper.selectJoinPage(ConventPage.getPage(dto), TextbookPageVo.class, textbookMPJLambdaWrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<TextbookPageVo> getPage(Page<TextbookPageDto> page, TextbookPageDto dto) {
|
|
|
- return textbookTextbookMapper.getPage(page, dto);
|
|
|
+ public List<TextbookListVo> listRubAndHand(TextbookListDto dto) {
|
|
|
+ MPJLambdaWrapper<Textbook> textbookMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ textbookMPJLambdaWrapper
|
|
|
+ .select(Textbook::getId)
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookListVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(SubjectGroup.class, SubjectGroup::getId, Textbook::getSubjectGroupId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(SubjectGroup::getGroupName, TextbookListVo::getGroupName)
|
|
|
+ .like(StringUtils.isNotBlank(dto.getGroupName()), SubjectGroup::getGroupName, dto.getGroupName())
|
|
|
+ )
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, Textbook::getCourseSubjectId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(BaseCourseSubject::getName, TextbookListVo::getCourseName)
|
|
|
+ .like(StringUtils.isNotBlank(dto.getCourseName()), BaseCourseSubject::getName, dto.getCourseName())
|
|
|
+ )
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, TextbookListVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getUseType()), Textbook::getUseType, dto.getUseType())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getIssn()), Textbook::getIssn, dto.getIssn())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getIsbn()), Textbook::getIsbn, dto.getIsbn())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getBookName()), Textbook::getBookName, dto.getBookName())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getPublishingHouse()), Textbook::getPublishingHouse, dto.getPublishingHouse())
|
|
|
+ .like(StringUtils.isNotBlank(dto.getEditorInChief()), Textbook::getEditorInChief, dto.getEditorInChief())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getVersion()), Textbook::getVersion, dto.getVersion())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getIsTextbookPlan()), Textbook::getIsTextbookPlan, dto.getIsTextbookPlan())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getTextbookType()), Textbook::getTextbookType, dto.getTextbookType())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getSpecificationsModels()), Textbook::getSpecificationsModels, dto.getSpecificationsModels())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getIsSecd()), Textbook::getIsSecd, dto.getIsSecd())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getCategory()), Textbook::getCategory, dto.getCategory())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getPlanBatch()), Textbook::getPlanBatch, dto.getPlanBatch())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getWorkTotalCount()), Textbook::getWorkTotalCount, dto.getWorkTotalCount())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getTextbookCategory()), Textbook::getTextbookCategory, dto.getTextbookCategory())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getPrice()), Textbook::getPrice, dto.getPrice())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getDiscount()), Textbook::getDiscount, dto.getDiscount())
|
|
|
+ ;
|
|
|
+
|
|
|
+ return textbookTextbookMapper.selectJoinList(TextbookListVo.class, textbookMPJLambdaWrapper);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/* @Override
|
|
|
@Transactional
|
|
|
public Boolean dataHandleAddTextbookNode(Long dataId) {
|
|
@@ -342,48 +366,40 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
@Transactional
|
|
|
public Boolean dataHandleAddExerciseBookNode(Long dataId) {
|
|
|
WfExerciseBook wfExerciseBook = wfExerciseBookService.selectById(dataId);
|
|
|
- if (ObjectUtil.isNotNull(wfExerciseBook) && ObjectUtil.isNotNull(wfExerciseBook.getWfExerciseBookItemList()) && wfExerciseBook.getWfExerciseBookItemList().size() > 0) {
|
|
|
+ if (ObjectUtils.isNotEmpty(wfExerciseBook) && ObjectUtils.isNotEmpty(wfExerciseBook.getWfExerciseBookItemList()) && wfExerciseBook.getWfExerciseBookItemList().size() > 0) {
|
|
|
for (WfExerciseBookItem wfExerciseBookItem : wfExerciseBook.getWfExerciseBookItemList()) {
|
|
|
Long semesterId = wfExerciseBook.getBaseSemesterId();
|
|
|
String bookName = wfExerciseBookItem.getSubscriptionType();//作业本的选择类型对应教材管理的书名
|
|
|
LambdaQueryWrapper<Textbook> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper
|
|
|
.eq(Textbook::getBookName, bookName)
|
|
|
- .eq(Textbook::getBaseSemesterId, semesterId);
|
|
|
+ ;
|
|
|
List<Textbook> textbookList = this.list(queryWrapper);
|
|
|
//征订的作业本没有在教材管理
|
|
|
- if (ObjectUtil.isNull(textbookList) || textbookList.size() == 0) {
|
|
|
+ if (ObjectUtils.isEmpty(textbookList) || textbookList.size() == 0) {
|
|
|
Textbook textbook = new Textbook() {{
|
|
|
setIssn("/");
|
|
|
setIsbn("/");
|
|
|
- if (ObjectUtil.isNotNull(wfExerciseBookItem.getSubscriptionType()) && wfExerciseBookItem.getSubscriptionType().equals(ExerciseBookeTypeEnum.ExerciseBook1.getCode())) {
|
|
|
+ if (ObjectUtils.isNotEmpty(wfExerciseBookItem.getSubscriptionType()) && wfExerciseBookItem.getSubscriptionType().equals(ExerciseBookeTypeEnum.ExerciseBook1.getCode())) {
|
|
|
setBookName(ExerciseBookeTypeEnum.ExerciseBook1.getValue());
|
|
|
}
|
|
|
- if (ObjectUtil.isNotNull(wfExerciseBookItem.getSubscriptionType()) && wfExerciseBookItem.getSubscriptionType().equals(ExerciseBookeTypeEnum.ExerciseBook2.getCode())) {
|
|
|
+ if (ObjectUtils.isNotEmpty(wfExerciseBookItem.getSubscriptionType()) && wfExerciseBookItem.getSubscriptionType().equals(ExerciseBookeTypeEnum.ExerciseBook2.getCode())) {
|
|
|
setBookName(ExerciseBookeTypeEnum.ExerciseBook2.getValue());
|
|
|
}
|
|
|
setPublishingHouse("/");
|
|
|
setEditorInChief("/");
|
|
|
- setBaseSemesterId(wfExerciseBook.getBaseSemesterId());
|
|
|
setVersion("/");
|
|
|
- setIsTextbookPlan("/");
|
|
|
setTextbookType(TextbookTypeEnum.TExerciseBook.getCode());
|
|
|
- setSpecificationsModels((ObjectUtil.isNull(wfExerciseBookItem.getSpecificationsModels()) || StringUtils.isBlank(wfExerciseBookItem.getSpecificationsModels())) ? "/" : wfExerciseBookItem.getSpecificationsModels());
|
|
|
+ setSpecificationsModels((ObjectUtils.isEmpty(wfExerciseBookItem.getSpecificationsModels()) || StringUtils.isBlank(wfExerciseBookItem.getSpecificationsModels())) ? "/" : wfExerciseBookItem.getSpecificationsModels());
|
|
|
//年级id
|
|
|
- if (ObjectUtil.isNotNull(wfExerciseBook.getClassId()) && wfExerciseBook.getClassId() > 0) {
|
|
|
+ if (ObjectUtils.isNotEmpty(wfExerciseBook.getClassId()) && wfExerciseBook.getClassId() > 0) {
|
|
|
LambdaQueryWrapper<BaseClass> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
queryWrapper1
|
|
|
.eq(BaseClass::getId, wfExerciseBook.getClassId());
|
|
|
BaseClass baseClass = baseClassService.getOne(queryWrapper1);
|
|
|
- if (ObjectUtil.isNotNull(baseClass)) {
|
|
|
- setGradeId(baseClass.getGradeId());
|
|
|
- }
|
|
|
}
|
|
|
- setAppraisalPrice((ObjectUtil.isNull(wfExerciseBookItem.getAppraisalPrice())) ? new BigDecimal(0) : wfExerciseBookItem.getAppraisalPrice());
|
|
|
setPrice(new BigDecimal(0));
|
|
|
setDiscount(10D);
|
|
|
- setSubtotal(new BigDecimal(0));
|
|
|
- setStock(0);
|
|
|
}};
|
|
|
|
|
|
//插入教材数据
|
|
@@ -391,7 +407,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
textbookTextbookMapper.insert(textbook);
|
|
|
|
|
|
//插入班级和教材关系
|
|
|
- if (ObjectUtil.isNotNull(wfExerciseBook.getClassId()) && wfExerciseBook.getClassId() > 0) {
|
|
|
+ if (ObjectUtils.isNotEmpty(wfExerciseBook.getClassId()) && wfExerciseBook.getClassId() > 0) {
|
|
|
textbookTextbookClassRelationMapper.insert(new TextbookClassRelation() {{
|
|
|
setCreateDate(new Date());
|
|
|
setTextbookId(textbook.getId());
|
|
@@ -411,7 +427,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
Textbook textbook = textbookList.get(0);
|
|
|
|
|
|
//班级不为空
|
|
|
- if (ObjectUtil.isNotNull(wfExerciseBook.getClassId()) && wfExerciseBook.getClassId() > 0) {
|
|
|
+ if (ObjectUtils.isNotEmpty(wfExerciseBook.getClassId()) && wfExerciseBook.getClassId() > 0) {
|
|
|
textbookTextbookClassRelationMapper.insert(new TextbookClassRelation() {{
|
|
|
setCreateDate(new Date());
|
|
|
setTextbookId(textbook.getId());
|
|
@@ -453,7 +469,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
if (textbook.getTextbookType().equals(TextbookTypeEnum.TTextbook.getCode()) || textbook.getTextbookType().equals(TextbookTypeEnum.TMaterials.getCode())) {
|
|
|
recordVos = textbookTextbookMapper.subscriptionList(id);
|
|
|
for (TextbookSubscriptionRecordVo recordVo : recordVos) {
|
|
|
- if (ObjectUtil.isNull(recordVo) || StrUtil.isEmpty(recordVo.getClassIds())) {
|
|
|
+ if (ObjectUtils.isEmpty(recordVo) || StrUtil.isEmpty(recordVo.getClassIds())) {
|
|
|
// recordVos.remove(recordVo);
|
|
|
// if (recordVos.isEmpty()) {
|
|
|
// break;
|
|
@@ -887,18 +903,18 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
return bot;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- 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;
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// @Transactional
|
|
|
+// 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;
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public IPage<TextbookSubscriptionListVo> getSubscriptionPageByClass(TextbookSubscriptionListDto dto) {
|
|
@@ -909,137 +925,179 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
}
|
|
|
dto.setClassIdList(classIdList);
|
|
|
|
|
|
- IPage<TextbookSubscriptionListVo> page = this.baseMapper.getSubscriptionPageByClass(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+ // 找到可以使用多个学期且已经征订的教材
|
|
|
+ MPJLambdaWrapper<BaseClassCourse> subscribedTextbook = new MPJLambdaWrapper<>();
|
|
|
+ subscribedTextbook
|
|
|
+ .distinct()
|
|
|
+ .select(BaseClassCourse::getId)
|
|
|
+ .innerJoin(TextbookSubscriptionClass.class, TextbookSubscriptionClass::getBaseClassId, BaseClassCourse::getClassId)
|
|
|
+ .innerJoin(TextbookSubscriptionItem.class, wrapper -> wrapper
|
|
|
+ .eq(TextbookSubscriptionItem::getTextbookSubscriptionId, TextbookSubscriptionClass::getTextbookSubscriptionId)
|
|
|
+ .eq(TextbookSubscriptionItem::getTextbookId, BaseClassCourse::getTextbookId)
|
|
|
+ )
|
|
|
+
|
|
|
+ .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
+ .gt(Textbook::getUseType, 1)
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getClassIdList())
|
|
|
+ ;
|
|
|
+ List<BaseClassCourse> baseClassCourses = baseClassCourseMapper.selectJoinList(BaseClassCourse.class, subscribedTextbook);
|
|
|
+
|
|
|
+ List<Long> baseClassCourseIds = baseClassCourses.stream()
|
|
|
+ .map(BaseClassCourse::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ MPJLambdaWrapper<BaseClassCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ baseClassCourseMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .distinct()
|
|
|
+ .selectAs(BaseClassCourse::getCourseId, TextbookSubscriptionListVo::getCourseSubjectId)
|
|
|
+ .selectAs(BaseClassCourse::getTextbookId, TextbookSubscriptionListVo::getTextbookId)
|
|
|
+ .selectAs(BaseCourseSubject::getName, TextbookSubscriptionListVo::getCourseName)
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookSubscriptionListVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, TextbookSubscriptionListVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getClassIdList())
|
|
|
+ .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(Textbook::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+ IPage<TextbookSubscriptionListVo> textbookSubscriptionListVoIPage = baseClassCourseMapper.selectJoinPage(ConventPage.getPage(dto), TextbookSubscriptionListVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
+// IPage<TextbookSubscriptionListVo> page = this.baseMapper.getSubscriptionPageByClass(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
|
|
|
// 处理每本教材使用的人数
|
|
|
if(!classIdList.isEmpty()) {
|
|
|
- for(TextbookSubscriptionListVo t : page.getRecords()){
|
|
|
- MPJLambdaWrapper<BaseClassCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
- baseClassCourseMPJLambdaWrapper
|
|
|
+ for(TextbookSubscriptionListVo t : textbookSubscriptionListVoIPage.getRecords()){
|
|
|
+ MPJLambdaWrapper<BaseClassCourse> countNum = new MPJLambdaWrapper<>();
|
|
|
+ countNum
|
|
|
.innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseClassCourse::getClassId)
|
|
|
- .in(BaseClassCourse::getClassId, classIdList)
|
|
|
- .eq(BaseClassCourse::getTextbookId, t.getId())
|
|
|
- .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
.eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
+ .eq(BaseClassCourse::getTextbookId, t.getTextbookId())
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getClassIdList())
|
|
|
+ .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
;
|
|
|
- Long num = baseClassCourseMapper.selectCount(baseClassCourseMPJLambdaWrapper);
|
|
|
+ Long num = baseClassCourseMapper.selectCount(countNum);
|
|
|
t.setStudentSubscriptionNumber(num.intValue());
|
|
|
|
|
|
t.setClassIds(dto.getClassIds());
|
|
|
- if(t.getTextbookType() != null && !t.getTextbookType().isEmpty()){
|
|
|
- t.setTextbookTypeCn(TextbookTypeEnum.getValue(t.getTextbookType()));
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return page;
|
|
|
+ return textbookSubscriptionListVoIPage;
|
|
|
}
|
|
|
|
|
|
- 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 isSecd = textbookImportDto.getIsSecd();
|
|
|
- Integer isSecdI = Optional.ofNullable(isSecd)
|
|
|
- .filter("是"::equals)
|
|
|
- .map(s -> 1)
|
|
|
- .orElse(0);
|
|
|
- textbook.setIsSecd(isSecdI);
|
|
|
-
|
|
|
- // 处理教材类型映射
|
|
|
- String textbookTypeCn = textbookImportDto.getTextbookTypeCn();
|
|
|
- String textbookTypeCode = Optional.ofNullable(textbookTypeCn)
|
|
|
- .map(TextbookTypeEnum::getCode)
|
|
|
- .orElse(null);
|
|
|
- textbook.setTextbookType(textbookTypeCode);
|
|
|
-
|
|
|
- //处理使用类型
|
|
|
- textbook.setUseType(UseSemesterTypeEnum.getCode(textbookImportDto.getUseTypeCn()));
|
|
|
- Double discount = 1d;
|
|
|
- if(textbook.getDiscount() != null){
|
|
|
- discount = textbook.getDiscount();
|
|
|
- }
|
|
|
- //处理小计
|
|
|
- textbook.setSubtotal(textbook.getPrice().multiply(BigDecimal.valueOf(discount / 10)));
|
|
|
-
|
|
|
- // 判断导入的教材是否已经存在,根据教材的 ISBN 码和使用的学期判断
|
|
|
- LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- textbookLambdaQueryWrapper
|
|
|
- .eq(Textbook::getIssn, textbook.getIssn())
|
|
|
- ;
|
|
|
-
|
|
|
- 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.setCreateDate(now);
|
|
|
- textbook.setCreateUserId(loginId);
|
|
|
- textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
|
|
|
- textbookTextbookMapper.insert(textbook);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// 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 isSecd = textbookImportDto.getIsSecd();
|
|
|
+// Integer isSecdI = Optional.ofNullable(isSecd)
|
|
|
+// .filter("是"::equals)
|
|
|
+// .map(s -> 1)
|
|
|
+// .orElse(0);
|
|
|
+// textbook.setIsSecd(isSecdI);
|
|
|
+//
|
|
|
+// // 处理教材类型映射
|
|
|
+// String textbookTypeCn = textbookImportDto.getTextbookTypeCn();
|
|
|
+// String textbookTypeCode = Optional.ofNullable(textbookTypeCn)
|
|
|
+// .map(TextbookTypeEnum::getCode)
|
|
|
+// .orElse(null);
|
|
|
+// textbook.setTextbookType(textbookTypeCode);
|
|
|
+//
|
|
|
+// //处理使用类型
|
|
|
+// textbook.setUseType(UseSemesterTypeEnum.getCode(textbookImportDto.getUseTypeCn()));
|
|
|
+// Double discount = 1d;
|
|
|
+// if(textbook.getDiscount() != null){
|
|
|
+// discount = textbook.getDiscount();
|
|
|
+// }
|
|
|
+// //处理小计
|
|
|
+// textbook.setSubtotal(textbook.getPrice().multiply(BigDecimal.valueOf(discount / 10)));
|
|
|
+//
|
|
|
+// // 判断导入的教材是否已经存在,根据教材的 ISBN 码和使用的学期判断
|
|
|
+// LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+// textbookLambdaQueryWrapper
|
|
|
+// .eq(Textbook::getIssn, textbook.getIssn())
|
|
|
+// ;
|
|
|
+//
|
|
|
+// 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.setCreateDate(now);
|
|
|
+// textbook.setCreateUserId(loginId);
|
|
|
+// textbook.setTextbookCoreAttributeId(textbookCoreAttribute.getId());
|
|
|
+// textbookTextbookMapper.insert(textbook);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean deliverWarehouse(AddTextbookWarehouseRecordDto dto) {
|
|
|
//根据id获取教材管理记录
|
|
|
Textbook textbook = this.getById(dto.getTextbookId());
|
|
|
- if (ObjectUtil.isNull(textbook)) {
|
|
|
+ if (ObjectUtils.isEmpty(textbook)) {
|
|
|
throw new MyException("入库失败,该教材不存在");
|
|
|
}
|
|
|
|
|
@@ -1050,8 +1108,6 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
this.updateById(new Textbook() {
|
|
|
{
|
|
|
setId(textbook.getId());
|
|
|
- Integer oldStock = ObjectUtil.isNull(textbook.getStock()) ? 0 : textbook.getStock();
|
|
|
- setStock(oldStock + (ObjectUtil.isNull(dto.getWarehouseNumber()) ? 0 : dto.getWarehouseNumber()));
|
|
|
// setPrice(price);
|
|
|
// setDiscount(discount);
|
|
|
// setSubtotal(subtotal);
|
|
@@ -1062,7 +1118,6 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
TextbookWarehouseRecord textbookWarehouseRecord = BeanUtil.toBean(dto, TextbookWarehouseRecord.class);
|
|
|
textbookWarehouseRecord.setWarehouseMode(WarehouseModeEnum.WmManual.getCode());
|
|
|
textbookWarehouseRecord.setDiscount(textbook.getDiscount());
|
|
|
- textbookWarehouseRecord.setSubtotal(textbook.getSubtotal());
|
|
|
textbookWarehouseRecord.setCreateDate(new Date());
|
|
|
QueryWrapper<TextbookWarehouseRecord> queryWrapperSortcode = new QueryWrapper<>();
|
|
|
queryWrapperSortcode.select("IFNULL(MAX(sort_code),0) as sortCode");
|