企业管理-员工信息
This commit is contained in:
parent
7be21f71f3
commit
5653726bd2
@ -7,4 +7,5 @@ public interface CommonErrorCodeConstants extends ErrorCodeConstants {
|
||||
|
||||
/** 企业管理-员工管理 */
|
||||
ErrorCode UNIQUE_CODE_CREATE_REPEAT = new ErrorCode(2_002_000_000, "唯一推广码生成失败");
|
||||
ErrorCode STAFF_CHANGE_CREATE_REPEAT = new ErrorCode(2_002_000_001, "交出或接收员工已有交接记录");
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.staff.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
|
||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
|
||||
import cn.iocoder.yudao.module.staff.mapper.CompanyStaffChangeMapper;
|
||||
@ -13,13 +14,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 企业管理-员工交接记录 接口实现类
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:40 2024/8/8
|
||||
**/
|
||||
**/
|
||||
@Service
|
||||
public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChangeMapper, CompanyStaffChange> implements CompanyStaffChangeService {
|
||||
|
||||
@ -28,34 +31,50 @@ public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChang
|
||||
|
||||
/**
|
||||
* 创建交接记录
|
||||
*
|
||||
* @param staffChangeRespVO
|
||||
* @author 小李
|
||||
* @date 16:15 2024/8/8
|
||||
* @param staffChangeRespVO
|
||||
**/
|
||||
public void createChangeStaff(CompanyStaffChangeRespVO staffChangeRespVO){
|
||||
public void createChangeStaff(CompanyStaffChangeRespVO staffChangeRespVO) {
|
||||
// 检查是否已有相同的交接记录或交出方已经交出或接收方已接收其他工作
|
||||
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>().and(itme -> {
|
||||
itme.eq("old_user_id", staffChangeRespVO.getOldUserId())
|
||||
.eq("new_user_id", staffChangeRespVO.getNewUserId());
|
||||
}).or().eq("old_user_id", staffChangeRespVO.getOldUserId())
|
||||
.or().eq("new_user_id", staffChangeRespVO.getNewUserId()));
|
||||
if (ObjectUtil.isNotEmpty(staffChange)) {
|
||||
throw exception(CommonErrorCodeConstants.STAFF_CHANGE_CREATE_REPEAT);
|
||||
}
|
||||
baseMapper.insert(staffChangeRespVO);
|
||||
// TODO 交接工作记录待完成
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询交接双方信息
|
||||
*
|
||||
* @param id 接收方员工ID
|
||||
* @author 小李
|
||||
* @date 18:26 2024/8/8
|
||||
* @param id 接收方员工ID
|
||||
**/
|
||||
@Override
|
||||
public CompanyStaffChangeRespVO getChangeStaff(String id){
|
||||
public CompanyStaffChangeRespVO getChangeStaff(String id) {
|
||||
/** 构造返回对象 */
|
||||
CompanyStaffChangeRespVO result = null;
|
||||
// 1 根据当前ID获取员工记录
|
||||
CompanyStaff newStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("id", id));
|
||||
CompanyStaff staff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("id", id));
|
||||
// 2 根据获取的员工信息中的userId获取交接记录
|
||||
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>().eq("new_user_id", newStaff.getUserId()));
|
||||
if (ObjectUtil.isNotEmpty(staffChange)){
|
||||
result = new CompanyStaffChangeRespVO();
|
||||
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>()
|
||||
.eq("new_user_id", staff.getUserId())
|
||||
.or()
|
||||
.eq("old_user_id", staff.getUserId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(staffChange)) {
|
||||
result = new CompanyStaffChangeRespVO();
|
||||
BeanUtil.copyProperties(staffChange, result);
|
||||
// 3 根据交接记录中老员工的userId查老员工信息
|
||||
// 3 根据交接记录中新老员工的userId查新老员工信息
|
||||
CompanyStaff oldStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("user_id", staffChange.getOldUserId()));
|
||||
CompanyStaff newStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("user_id", staffChange.getNewUserId()));
|
||||
result.setNewStaff(newStaff);
|
||||
result.setOldStaff(oldStaff);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user