|
@@ -1,6 +1,7 @@
|
|
|
package com.xjrsoft.module.teacher.service.impl;
|
|
package com.xjrsoft.module.teacher.service.impl;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.convert.Convert;
|
|
@@ -14,21 +15,33 @@ import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
import com.xjrsoft.common.enums.RoleEnum;
|
|
import com.xjrsoft.common.enums.RoleEnum;
|
|
|
|
|
+import com.xjrsoft.common.enums.TeaChangeTypeEnum;
|
|
|
|
|
+import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
|
|
+import com.xjrsoft.module.liteflow.node.WfTeacherDepartNode;
|
|
|
import com.xjrsoft.module.organization.entity.*;
|
|
import com.xjrsoft.module.organization.entity.*;
|
|
|
import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
|
|
import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
|
|
|
import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
|
|
import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
|
|
|
import com.xjrsoft.module.organization.service.*;
|
|
import com.xjrsoft.module.organization.service.*;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryItem;
|
|
|
import com.xjrsoft.module.system.service.IDictionarydetailService;
|
|
import com.xjrsoft.module.system.service.IDictionarydetailService;
|
|
|
import com.xjrsoft.module.teacher.dto.AddXjrUserDto;
|
|
import com.xjrsoft.module.teacher.dto.AddXjrUserDto;
|
|
|
import com.xjrsoft.module.teacher.dto.UpdateXjrUserDto;
|
|
import com.xjrsoft.module.teacher.dto.UpdateXjrUserDto;
|
|
|
import com.xjrsoft.module.teacher.entity.*;
|
|
import com.xjrsoft.module.teacher.entity.*;
|
|
|
import com.xjrsoft.module.teacher.mapper.*;
|
|
import com.xjrsoft.module.teacher.mapper.*;
|
|
|
|
|
+import com.xjrsoft.module.teacher.service.IBaseTeacherChangeRecordService;
|
|
|
import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
|
|
import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
|
|
|
|
|
+import com.xjrsoft.module.textbook.entity.WfTextbookRecede;
|
|
|
|
|
+import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
|
|
|
|
|
+import com.xjrsoft.module.workflow.mapper.WorkflowFormRelationMapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -65,8 +78,15 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
private final IDictionarydetailService dictionaryService;
|
|
private final IDictionarydetailService dictionaryService;
|
|
|
private final IDepartmentService departmentService;
|
|
private final IDepartmentService departmentService;
|
|
|
private final IPostService postService;
|
|
private final IPostService postService;
|
|
|
|
|
+ private final BaseTeacherMapper baseTeacherMapper;
|
|
|
private IDictionarydetailService dictionarydetailService;
|
|
private IDictionarydetailService dictionarydetailService;
|
|
|
|
|
|
|
|
|
|
+ private WfTeacherDepartMapper wfTeacherDepartMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private BaseTeacherChangeRecordMapper baseTeacherChangeRecordMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private WorkflowFormRelationMapper workflowFormRelationMapper;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -181,6 +201,64 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean update(UpdateXjrUserDto dto) {
|
|
public Boolean update(UpdateXjrUserDto dto) {
|
|
|
|
|
+ XjrUser old = this.getByIdDeep(dto.getId());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(old)){
|
|
|
|
|
+ throw new MyException("教职工信息不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理在职状态
|
|
|
|
|
+ // 获取字典值
|
|
|
|
|
+ List<DictionaryDetail> detailList = dictionarydetailService.list(
|
|
|
|
|
+ new MPJLambdaWrapper<DictionaryDetail>()
|
|
|
|
|
+ .select(DictionaryDetail::getId)
|
|
|
|
|
+ .select(DictionaryDetail.class, x -> VoToColumnUtil.fieldsToColumns(DictionaryDetail.class).contains(x.getProperty()))
|
|
|
|
|
+ .leftJoin(DictionaryItem.class, DictionaryItem::getId, DictionaryDetail::getItemId)
|
|
|
|
|
+ .eq(DictionaryItem::getCode, "job_state")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> dictionaryDetailMap = detailList.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(DictionaryDetail::getCode, DictionaryDetail::getName));
|
|
|
|
|
+
|
|
|
|
|
+ // 定义常量
|
|
|
|
|
+ final String NO_JOB_STATE = "无在职状态";
|
|
|
|
|
+
|
|
|
|
|
+ // 获取新旧在职状态
|
|
|
|
|
+ String oldJobState = null;
|
|
|
|
|
+ String newJobState = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(old.getBaseTeacherList()) && StringUtils.isNotEmpty(old.getBaseTeacherList().get(0).getJobState())) {
|
|
|
|
|
+ oldJobState = old.getBaseTeacherList().get(0).getJobState();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getBaseTeacherList()) && StringUtils.isNotEmpty(dto.getBaseTeacherList().get(0).getJobState())) {
|
|
|
|
|
+ newJobState = dto.getBaseTeacherList().get(0).getJobState();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 只有在职状态被修改时,才触发 insert
|
|
|
|
|
+ if (!Objects.equals(oldJobState, newJobState)) {
|
|
|
|
|
+ BaseTeacherChangeRecord insetBaseTeacherChangeRecord = new BaseTeacherChangeRecord();
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setCreateDate(new Date());
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setUserId(dto.getId());
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setChangeType(TeaChangeTypeEnum.TCT0001.getCode());
|
|
|
|
|
+
|
|
|
|
|
+ // 设置旧状态
|
|
|
|
|
+ if (StringUtils.isNotEmpty(oldJobState)) {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setOldJobState(dictionaryDetailMap.getOrDefault(oldJobState, oldJobState));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setOldJobState(NO_JOB_STATE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置新状态
|
|
|
|
|
+ if (StringUtils.isNotEmpty(newJobState)) {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setNewJobState(dictionaryDetailMap.getOrDefault(newJobState, newJobState));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setNewJobState(NO_JOB_STATE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 插入变更记录
|
|
|
|
|
+ baseTeacherChangeRecordMapper.insert(insetBaseTeacherChangeRecord);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
XjrUser xjrUser = BeanUtil.toBean(dto, XjrUser.class);
|
|
XjrUser xjrUser = BeanUtil.toBean(dto, XjrUser.class);
|
|
|
|
|
|
|
@@ -645,4 +723,91 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void teacherDepartDataHandle(Long formId) {
|
|
|
|
|
+ WfTeacherDepart wfTextbookRecede = wfTeacherDepartMapper.selectById(formId);
|
|
|
|
|
+
|
|
|
|
|
+ Date nowDate = new Date();
|
|
|
|
|
+
|
|
|
|
|
+ // 根据数据id找到所在流程得状态
|
|
|
|
|
+ WorkflowFormRelation workflowFormRelation = workflowFormRelationMapper.selectOne(
|
|
|
|
|
+ Wrappers.lambdaQuery(WorkflowFormRelation.class)
|
|
|
|
|
+ .eq(WorkflowFormRelation::getFormKeyValue, formId)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(wfTextbookRecede)
|
|
|
|
|
+ && ObjectUtils.isNotEmpty(workflowFormRelation)
|
|
|
|
|
+ && HistoricProcessInstance.STATE_COMPLETED.equals(workflowFormRelation.getCurrentState())
|
|
|
|
|
+ ) {
|
|
|
|
|
+ XjrUser old = this.getByIdDeep(wfTextbookRecede.getApplicantUserId());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(old)){
|
|
|
|
|
+ throw new MyException("教职工信息不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理在职状态
|
|
|
|
|
+ // 更新教职工在职状态
|
|
|
|
|
+ List<BaseTeacher> baseTeacherList = old.getBaseTeacherList();
|
|
|
|
|
+ BaseTeacher updateBaseTeacher;
|
|
|
|
|
+ for (BaseTeacher baseTeacher : baseTeacherList){
|
|
|
|
|
+ updateBaseTeacher = new BaseTeacher();
|
|
|
|
|
+ updateBaseTeacher.setId(baseTeacher.getId());
|
|
|
|
|
+ updateBaseTeacher.setJobState("JOB_LZ");
|
|
|
|
|
+ baseTeacherMapper.updateById(updateBaseTeacher);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理变更记录
|
|
|
|
|
+ // 获取字典值
|
|
|
|
|
+ List<DictionaryDetail> detailList = dictionarydetailService.list(
|
|
|
|
|
+ new MPJLambdaWrapper<DictionaryDetail>()
|
|
|
|
|
+ .select(DictionaryDetail::getId)
|
|
|
|
|
+ .select(DictionaryDetail.class, x -> VoToColumnUtil.fieldsToColumns(DictionaryDetail.class).contains(x.getProperty()))
|
|
|
|
|
+ .leftJoin(DictionaryItem.class, DictionaryItem::getId, DictionaryDetail::getItemId)
|
|
|
|
|
+ .eq(DictionaryItem::getCode, "job_state")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> dictionaryDetailMap = detailList.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(DictionaryDetail::getCode, DictionaryDetail::getName));
|
|
|
|
|
+
|
|
|
|
|
+ // 定义常量
|
|
|
|
|
+ final String NO_JOB_STATE = "无在职状态";
|
|
|
|
|
+
|
|
|
|
|
+ // 获取新旧在职状态
|
|
|
|
|
+ String oldJobState = null;
|
|
|
|
|
+ String newJobState = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(old.getBaseTeacherList()) && StringUtils.isNotEmpty(old.getBaseTeacherList().get(0).getJobState())) {
|
|
|
|
|
+ oldJobState = old.getBaseTeacherList().get(0).getJobState();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ newJobState = "JOB_LZ";
|
|
|
|
|
+
|
|
|
|
|
+ // 只有在职状态被修改时,才触发 insert
|
|
|
|
|
+ if (!Objects.equals(oldJobState, newJobState)) {
|
|
|
|
|
+ BaseTeacherChangeRecord insetBaseTeacherChangeRecord = new BaseTeacherChangeRecord();
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setCreateDate(new Date());
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setUserId(wfTextbookRecede.getApplicantUserId());
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setChangeType(TeaChangeTypeEnum.TCT0001.getCode());
|
|
|
|
|
+
|
|
|
|
|
+ // 设置旧状态
|
|
|
|
|
+ if (StringUtils.isNotEmpty(oldJobState)) {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setOldJobState(dictionaryDetailMap.getOrDefault(oldJobState, oldJobState));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setOldJobState(NO_JOB_STATE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置新状态
|
|
|
|
|
+ if (StringUtils.isNotEmpty(newJobState)) {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setNewJobState(dictionaryDetailMap.getOrDefault(newJobState, newJobState));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insetBaseTeacherChangeRecord.setNewJobState(NO_JOB_STATE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 插入变更记录
|
|
|
|
|
+ baseTeacherChangeRecordMapper.insert(insetBaseTeacherChangeRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|