|
@@ -1,11 +1,13 @@
|
|
|
package com.xjrsoft.module.banding.service.impl;
|
|
package com.xjrsoft.module.banding.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.enums.YesOrNoEnum;
|
|
import com.xjrsoft.common.enums.YesOrNoEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
import com.xjrsoft.common.model.result.RT;
|
|
@@ -36,6 +38,7 @@ import com.xjrsoft.module.system.entity.DictionaryItem;
|
|
|
import com.xjrsoft.module.system.mapper.DictionarydetailMapper;
|
|
import com.xjrsoft.module.system.mapper.DictionarydetailMapper;
|
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
+import org.camunda.bpm.engine.TaskService;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -211,14 +214,25 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
|
|
|
public Boolean saveClass(List<UpdateBandingClassDto> dtoList) {
|
|
public Boolean saveClass(List<UpdateBandingClassDto> dtoList) {
|
|
|
List<BandingTaskClass> insList = new ArrayList<>();//新增班级
|
|
List<BandingTaskClass> insList = new ArrayList<>();//新增班级
|
|
|
List<BandingTaskClass> updList = new ArrayList<>();//修改班级
|
|
List<BandingTaskClass> updList = new ArrayList<>();//修改班级
|
|
|
- List<BandingTaskClass> updNullList = new ArrayList<>();
|
|
|
|
|
- List<String> errorList = new ArrayList<>();
|
|
|
|
|
|
|
+ List<BandingTaskClass> updNullList = new ArrayList<>();//修改班级
|
|
|
|
|
+ List<String> errorList = new ArrayList<>();//修改班级
|
|
|
|
|
|
|
|
- classMapper.selectList(
|
|
|
|
|
|
|
+ BandingTask task = bandingTaskMapper.selectById(dtoList.get(0).getBandingTaskId());
|
|
|
|
|
+ List<BaseClass> classList = classMapper.selectList(
|
|
|
new QueryWrapper<BaseClass>().lambda()
|
|
new QueryWrapper<BaseClass>().lambda()
|
|
|
.eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
.eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
|
|
+ .eq(BaseClass::getGradeId, task.getGradeId())
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ Map<String, BaseClass> classMap = classList.stream().collect(Collectors.toMap(BaseClass::getName, x -> x));
|
|
|
|
|
+ List<BaseClass> updateClassList = new ArrayList<>();//修改班级
|
|
|
|
|
+ List<BaseClass> insertClassList = new ArrayList<>();//修改班级
|
|
|
|
|
+
|
|
|
|
|
+ List<BaseMajorSet> majorSetList = majorSetService.list(
|
|
|
|
|
+ new QueryWrapper<BaseMajorSet>().lambda()
|
|
|
|
|
+ .eq(BaseMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Long, Long> majorDeptMap = majorSetList.stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
|
|
|
|
|
|
|
|
for (UpdateBandingClassDto dto : dtoList) {
|
|
for (UpdateBandingClassDto dto : dtoList) {
|
|
|
if(dto.getSortCode() != null){
|
|
if(dto.getSortCode() != null){
|
|
@@ -233,17 +247,37 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
|
|
|
|
|
- if(bandingTask.getId() != null){
|
|
|
|
|
- bandingTask.setModifyDate(new Date());
|
|
|
|
|
- if(bandingTask.getSortCode() == null){
|
|
|
|
|
- updNullList.add(bandingTask);
|
|
|
|
|
|
|
+ BandingTaskClass taskClass = BeanUtil.toBean(dto, BandingTaskClass.class);
|
|
|
|
|
+ if(taskClass.getId() != null){
|
|
|
|
|
+ taskClass.setModifyDate(new Date());
|
|
|
|
|
+ if(taskClass.getSortCode() == null){
|
|
|
|
|
+ updNullList.add(taskClass);
|
|
|
}else{
|
|
}else{
|
|
|
- updList.add(bandingTask);
|
|
|
|
|
|
|
+ updList.add(taskClass);
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
- bandingTask.setCreateDate(new Date());
|
|
|
|
|
- insList.add(bandingTask);
|
|
|
|
|
|
|
+ taskClass.setCreateDate(new Date());
|
|
|
|
|
+ insList.add(taskClass);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(classMap.containsKey(taskClass.getName())){
|
|
|
|
|
+ BaseClass baseClass = classMap.get(taskClass.getName());
|
|
|
|
|
+ baseClass.setClassType(taskClass.getClassType());
|
|
|
|
|
+ baseClass.setTeacherId(taskClass.getTeacherId());
|
|
|
|
|
+ baseClass.setMajorSetId(taskClass.getMajorSetId());
|
|
|
|
|
+ baseClass.setClassroomId(taskClass.getClassroomId());
|
|
|
|
|
+ baseClass.setIsOrderClass(taskClass.getIsOrderClass());
|
|
|
|
|
+ baseClass.setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
|
|
|
|
|
+ updateClassList.add(baseClass);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ BaseClass baseClass = new BaseClass();
|
|
|
|
|
+ baseClass.setClassType(taskClass.getClassType());
|
|
|
|
|
+ baseClass.setTeacherId(taskClass.getTeacherId());
|
|
|
|
|
+ baseClass.setMajorSetId(taskClass.getMajorSetId());
|
|
|
|
|
+ baseClass.setClassroomId(taskClass.getClassroomId());
|
|
|
|
|
+ baseClass.setIsOrderClass(taskClass.getIsOrderClass());
|
|
|
|
|
+ baseClass.setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
|
|
|
|
|
+ baseClass.setGradeId(task.getGradeId());
|
|
|
|
|
+ insertClassList.add(baseClass);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if(!errorList.isEmpty()){
|
|
if(!errorList.isEmpty()){
|
|
@@ -254,7 +288,74 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
|
|
|
this.updateNull(updNullList);
|
|
this.updateNull(updNullList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(!insertClassList.isEmpty()){
|
|
|
|
|
+ for (BaseClass baseClass : insertClassList) {
|
|
|
|
|
+ classMapper.insert(baseClass);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!updateClassList.isEmpty()){
|
|
|
|
|
+ for (BaseClass baseClass : updateClassList) {
|
|
|
|
|
+ classMapper.updateById(baseClass);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.saveBatch(insList);
|
|
this.saveBatch(insList);
|
|
|
return this.updateBatchById(updList);
|
|
return this.updateBatchById(updList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 班级管理中,修改信息时同步修改新生分班中的班级信息
|
|
|
|
|
+ * @param baseClass
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public Boolean updateByBaseClass(BaseClass baseClass) {
|
|
|
|
|
+ List<BandingTask> bandingTasks = bandingTaskMapper.selectList(
|
|
|
|
|
+ new QueryWrapper<BandingTask>().lambda()
|
|
|
|
|
+ .eq(BandingTask::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
|
|
+ .eq(BandingTask::getGradeId, baseClass.getGradeId())
|
|
|
|
|
+ .orderByDesc(BandingTask::getId)
|
|
|
|
|
+ .eq(BandingTask::getStatus, 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ if(bandingTasks.isEmpty()){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ BandingTaskClass one = this.getOne(
|
|
|
|
|
+ new MPJLambdaWrapper<BandingTaskClass>()
|
|
|
|
|
+ .select(BandingTask::getId)
|
|
|
|
|
+ .select(BandingTask.class, x -> VoToColumnUtil.fieldsToColumns(BandingTask.class).contains(x.getProperty()))
|
|
|
|
|
+ .innerJoin(BandingTask.class, BandingTask::getId, BandingTaskClass::getBandingTaskId)
|
|
|
|
|
+ .eq(BandingTaskClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
|
|
+ .eq(BandingTaskClass::getName, baseClass.getName())
|
|
|
|
|
+ .eq(BandingTask::getGradeId, baseClass.getGradeId())
|
|
|
|
|
+ .eq(BandingTask::getStatus, 1)
|
|
|
|
|
+ );
|
|
|
|
|
+ if(one == null){
|
|
|
|
|
+ BandingTask task = bandingTasks.get(0);
|
|
|
|
|
+ one = new BandingTaskClass();
|
|
|
|
|
+ one.setBandingTaskId(task.getId());
|
|
|
|
|
+ one.setIsOrderClass(baseClass.getIsOrderClass());
|
|
|
|
|
+ one.setClassType(baseClass.getClassType());
|
|
|
|
|
+ one.setTeacherId(baseClass.getTeacherId());
|
|
|
|
|
+ one.setMajorSetId(baseClass.getMajorSetId());
|
|
|
|
|
+ one.setClassroomId(baseClass.getClassroomId());
|
|
|
|
|
+ one.setDeleteMark(DeleteMark.NODELETE.getCode());
|
|
|
|
|
+ one.setCreateDate(new Date());
|
|
|
|
|
+ one.setEnabledMark(EnabledMark.ENABLED.getCode());
|
|
|
|
|
+ one.setName(baseClass.getName());
|
|
|
|
|
+ one.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
|
|
+ this.save(one);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ one.setIsOrderClass(baseClass.getIsOrderClass());
|
|
|
|
|
+ one.setClassType(baseClass.getClassType());
|
|
|
|
|
+ one.setTeacherId(baseClass.getTeacherId());
|
|
|
|
|
+ one.setMajorSetId(baseClass.getMajorSetId());
|
|
|
|
|
+ one.setClassroomId(baseClass.getClassroomId());
|
|
|
|
|
+ one.setModifyDate(new Date());
|
|
|
|
|
+ one.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
|
|
+ this.updateById(one);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|