|
|
@@ -1,28 +1,39 @@
|
|
|
package com.xjrsoft.module.base.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.enums.StudentChangeTypeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.base.dto.BaseClassMergeStudentPageDto;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseClassMerge;
|
|
|
import com.xjrsoft.module.base.entity.BaseClassMergeStudent;
|
|
|
+import com.xjrsoft.module.base.entity.BaseSystemConfig;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMergeMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMergeStudentMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassMergeService;
|
|
|
+import com.xjrsoft.module.base.service.IBaseSystemConfigService;
|
|
|
import com.xjrsoft.module.base.vo.BaseClassMergeStudentVo;
|
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
+import com.xjrsoft.module.student.entity.StudentChangeClass;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
|
|
|
+import com.xjrsoft.module.student.mapper.StudentChangeClassMapper;
|
|
|
import com.xjrsoft.module.student.service.IStudentChangeRecordService;
|
|
|
+import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -47,6 +58,8 @@ public class BaseClassMergeServiceImpl extends MPJBaseServiceImpl<BaseClassMerge
|
|
|
private final BaseClassMapper baseClassMapper;
|
|
|
private final BaseStudentSchoolRollMapper schoolRollMapper;
|
|
|
private final IStudentChangeRecordService changeRecordService;
|
|
|
+ private final IBaseSystemConfigService systemConfigService;
|
|
|
+ private final StudentChangeClassMapper studentChangeClassMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -56,6 +69,45 @@ public class BaseClassMergeServiceImpl extends MPJBaseServiceImpl<BaseClassMerge
|
|
|
if(collect.contains(baseClassMerge.getTargetClassId())){
|
|
|
throw new MyException("原有班级中不能包含目标班级,请重新选择原有班级");
|
|
|
}
|
|
|
+
|
|
|
+ BaseSystemConfig classNumberMax = systemConfigService.getOne(
|
|
|
+ new QueryWrapper<BaseSystemConfig>().lambda()
|
|
|
+ .eq(BaseSystemConfig::getCode, "classNumberMax")
|
|
|
+ );
|
|
|
+ if(classNumberMax != null){
|
|
|
+ int classNumberMaxNum = Integer.parseInt(classNumberMax.getValue());
|
|
|
+ Integer actualStudentCount = schoolRollMapper.selectJoinCount(
|
|
|
+ new MPJLambdaWrapper<BaseStudentSchoolRoll>()
|
|
|
+ .distinct()
|
|
|
+ .select(BaseStudentSchoolRoll::getUserId)
|
|
|
+ .innerJoin(User.class, User::getId, BaseStudentSchoolRoll::getUserId)
|
|
|
+ .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseStudentSchoolRoll::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
+ .eq(BaseStudentSchoolRoll::getClassId, baseClassMerge.getTargetClassId())
|
|
|
+ );
|
|
|
+
|
|
|
+ Integer count = studentChangeClassMapper.selectJoinCount(
|
|
|
+ new MPJLambdaWrapper<StudentChangeClass>()
|
|
|
+ .distinct()
|
|
|
+ .select(StudentChangeClass::getStudentUserId)
|
|
|
+ .innerJoin(WorkflowFormRelation.class, WorkflowFormRelation::getFormKeyValue, StudentChangeClass::getId)
|
|
|
+ .eq(WorkflowFormRelation::getCurrentState, HistoricProcessInstance.STATE_ACTIVE)
|
|
|
+ );
|
|
|
+
|
|
|
+ String sql = "SELECT DISTINCT student_user_id FROM temporary_change_class t1" +
|
|
|
+ " INNER JOIN xjr_workflow_form_relation t2 ON t1.id = CAST(t2.form_key_value AS SIGNED)" +
|
|
|
+ " WHERE t1.delete_mark = 0 AND t2.current_state = 'ACTIVE'";
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+
|
|
|
+ int classCount = actualStudentCount + count + list.size();
|
|
|
+ int difference = classCount - classNumberMaxNum;
|
|
|
+ int absoluteValue = (difference < 0) ? -difference : difference;
|
|
|
+ if(baseClassMerge.getBaseClassMergeStudentList().size() > absoluteValue){
|
|
|
+ throw new MyException("转入班级的人数大于班级剩余空位,该班级剩余" + absoluteValue + "人");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
baseClassMerge.setStudentCount(baseClassMerge.getBaseClassMergeStudentList().size());
|
|
|
this.baseMapper.insert(baseClassMerge);
|
|
|
BaseClass baseClass = baseClassMapper.selectById(baseClassMerge.getTargetClassId());
|