|
@@ -1,6 +1,7 @@
|
|
|
package com.xjrsoft.module.teacher.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
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.GenderDictionaryEnum;
|
|
|
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.VoToColumnUtil;
|
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
+import com.xjrsoft.module.liteflow.node.WfTeacherDepartNode;
|
|
|
import com.xjrsoft.module.organization.entity.*;
|
|
|
import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
|
|
|
import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
|
|
|
import com.xjrsoft.module.organization.service.*;
|
|
|
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.teacher.dto.AddXjrUserDto;
|
|
|
import com.xjrsoft.module.teacher.dto.UpdateXjrUserDto;
|
|
|
import com.xjrsoft.module.teacher.entity.*;
|
|
|
import com.xjrsoft.module.teacher.mapper.*;
|
|
|
+import com.xjrsoft.module.teacher.service.IBaseTeacherChangeRecordService;
|
|
|
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 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.transaction.annotation.Transactional;
|
|
|
|
|
@@ -67,6 +80,12 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
private final IPostService postService;
|
|
|
private IDictionarydetailService dictionarydetailService;
|
|
|
|
|
|
+ private WfTeacherDepartMapper wfTeacherDepartMapper;
|
|
|
+
|
|
|
+ private BaseTeacherChangeRecordMapper baseTeacherChangeRecordMapper;
|
|
|
+
|
|
|
+ private WorkflowFormRelationMapper workflowFormRelationMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -181,6 +200,64 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
|
|
@@ -645,4 +722,80 @@ 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();
|
|
|
+
|
|
|
+
|
|
|
+ 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<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";
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|