Merge branch 'master' of http://122.51.230.86:3000/dianliang/lanan-system
This commit is contained in:
commit
c322cfb0ba
@ -7,4 +7,5 @@ public interface CommonErrorCodeConstants extends ErrorCodeConstants {
|
|||||||
|
|
||||||
/** 企业管理-员工管理 */
|
/** 企业管理-员工管理 */
|
||||||
ErrorCode UNIQUE_CODE_CREATE_REPEAT = new ErrorCode(2_002_000_000, "唯一推广码生成失败");
|
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.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
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.CompanyStaff;
|
||||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
|
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
|
||||||
import cn.iocoder.yudao.module.staff.mapper.CompanyStaffChangeMapper;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业管理-员工交接记录 接口实现类
|
* 企业管理-员工交接记录 接口实现类
|
||||||
|
*
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 15:40 2024/8/8
|
* @date 15:40 2024/8/8
|
||||||
**/
|
**/
|
||||||
@Service
|
@Service
|
||||||
public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChangeMapper, CompanyStaffChange> implements CompanyStaffChangeService {
|
public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChangeMapper, CompanyStaffChange> implements CompanyStaffChangeService {
|
||||||
|
|
||||||
@ -28,34 +31,50 @@ public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChang
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建交接记录
|
* 创建交接记录
|
||||||
|
*
|
||||||
|
* @param staffChangeRespVO
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 16:15 2024/8/8
|
* @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);
|
baseMapper.insert(staffChangeRespVO);
|
||||||
// TODO 交接工作记录待完成
|
// TODO 交接工作记录待完成
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询交接双方信息
|
* 查询交接双方信息
|
||||||
|
*
|
||||||
|
* @param id 接收方员工ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 18:26 2024/8/8
|
* @date 18:26 2024/8/8
|
||||||
* @param id 接收方员工ID
|
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public CompanyStaffChangeRespVO getChangeStaff(String id){
|
public CompanyStaffChangeRespVO getChangeStaff(String id) {
|
||||||
/** 构造返回对象 */
|
/** 构造返回对象 */
|
||||||
CompanyStaffChangeRespVO result = null;
|
CompanyStaffChangeRespVO result = null;
|
||||||
// 1 根据当前ID获取员工记录
|
// 1 根据当前ID获取员工记录
|
||||||
CompanyStaff newStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("id", id));
|
CompanyStaff staff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("id", id));
|
||||||
// 2 根据获取的员工信息中的userId获取交接记录
|
// 2 根据获取的员工信息中的userId获取交接记录
|
||||||
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>().eq("new_user_id", newStaff.getUserId()));
|
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>()
|
||||||
if (ObjectUtil.isNotEmpty(staffChange)){
|
.eq("new_user_id", staff.getUserId())
|
||||||
|
.or()
|
||||||
|
.eq("old_user_id", staff.getUserId())
|
||||||
|
);
|
||||||
|
if (ObjectUtil.isNotEmpty(staffChange)) {
|
||||||
result = new CompanyStaffChangeRespVO();
|
result = new CompanyStaffChangeRespVO();
|
||||||
BeanUtil.copyProperties(staffChange, result);
|
BeanUtil.copyProperties(staffChange, result);
|
||||||
// 3 根据交接记录中老员工的userId查老员工信息
|
// 3 根据交接记录中新老员工的userId查新老员工信息
|
||||||
CompanyStaff oldStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("user_id", staffChange.getOldUserId()));
|
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.setNewStaff(newStaff);
|
||||||
result.setOldStaff(oldStaff);
|
result.setOldStaff(oldStaff);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user