|
@@ -1,20 +1,30 @@
|
|
|
package com.jeeplus.business.humanResources.service;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.jeeplus.business.humanResources.domain.RegularApply;
|
|
|
import com.jeeplus.business.humanResources.domain.StaffUserInfo;
|
|
|
+import com.jeeplus.business.humanResources.mapper.RegularApplyMapper;
|
|
|
import com.jeeplus.business.humanResources.mapper.StaffUserInfoMapper;
|
|
|
import com.jeeplus.business.humanResources.service.dto.StaffUserInfoDTO;
|
|
|
+import com.jeeplus.common.SecurityUtils;
|
|
|
import com.jeeplus.common.TokenProvider;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
import com.jeeplus.sys.domain.WorkAttachmentInfo;
|
|
|
+import com.jeeplus.sys.feign.IPostApi;
|
|
|
+import com.jeeplus.sys.feign.IRoleApi;
|
|
|
import com.jeeplus.sys.feign.IUserApi;
|
|
|
import com.jeeplus.sys.feign.IWorkAttachmentApi;
|
|
|
+import com.jeeplus.sys.service.dto.OfficeDTO;
|
|
|
+import com.jeeplus.sys.service.dto.PostDTO;
|
|
|
+import com.jeeplus.sys.service.dto.RoleDTO;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.utils.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -29,6 +39,9 @@ public class StaffUserInfoService {
|
|
|
@Resource
|
|
|
private StaffUserInfoMapper staffUserInfoMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RegularApplyMapper regularApplyMapper;
|
|
|
+
|
|
|
public IPage<StaffUserInfoDTO> findPageList(StaffUserInfoDTO userInfoDTO, Page<StaffUserInfoDTO> page) throws Exception {
|
|
|
QueryWrapper<StaffUserInfoDTO> queryWrapper = QueryWrapperGenerator.buildQueryCondition(userInfoDTO, StaffUserInfoDTO.class);
|
|
|
queryWrapper.eq("a.del_flag",0);
|
|
@@ -171,36 +184,89 @@ public class StaffUserInfoService {
|
|
|
*/
|
|
|
public String saveForm(StaffUserInfoDTO staffUserInfoDTO) {
|
|
|
String id="";
|
|
|
- //根据姓名获取员工信息
|
|
|
- UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getUserDTOByName(staffUserInfoDTO.getName());
|
|
|
+ //获取当前登陆人信息
|
|
|
+ UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
String userId="";
|
|
|
- if (ObjectUtils.isNotEmpty(userDTO)){
|
|
|
- userId=userDTO.getId();
|
|
|
- }else {
|
|
|
- UserDTO dto = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
- userId=dto.getId();
|
|
|
- }
|
|
|
StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(staffUserInfoDTO,staffUserInfo);
|
|
|
+
|
|
|
+ staffUserInfo.setUpdateById(userDTO.getId());
|
|
|
+ staffUserInfo.setUpdateTime(new Date());
|
|
|
String roleId="";
|
|
|
+ ArrayList<RoleDTO> roleDTOS = new ArrayList<>();
|
|
|
//获取角色
|
|
|
if (ObjectUtils.isNotEmpty(staffUserInfoDTO.getRoleIdList())){
|
|
|
for (String role : staffUserInfoDTO.getRoleIdList()) {
|
|
|
+ RoleDTO roleDTO = SpringUtil.getBean(IRoleApi.class).getRoleDTOById(role);
|
|
|
+ roleDTOS.add(roleDTO);
|
|
|
roleId+=role+",";
|
|
|
}
|
|
|
- }else {
|
|
|
- roleId=userDTO.getRoleIds();
|
|
|
}
|
|
|
//获取岗位
|
|
|
String postId="";
|
|
|
+ ArrayList<PostDTO> postDTOS = new ArrayList<>();
|
|
|
+ PostDTO postDTO = new PostDTO();
|
|
|
if (ObjectUtils.isNotEmpty(staffUserInfoDTO.getPostIdList())){
|
|
|
for (String post : staffUserInfoDTO.getPostIdList()) {
|
|
|
+ postDTO.setId(post);
|
|
|
postId+=post+",";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- BeanUtils.copyProperties(staffUserInfoDTO,staffUserInfo);
|
|
|
+ postDTOS.addAll(postDTOS);
|
|
|
staffUserInfo.setPostId(postId);
|
|
|
staffUserInfo.setRoleId(roleId);
|
|
|
+
|
|
|
+ //审核通过的时候往用户表中新增一条数据
|
|
|
+ if (StringUtils.isNotBlank(staffUserInfo.getType())){
|
|
|
+ if ("5".equals(staffUserInfo.getType())){
|
|
|
+ StaffUserInfoDTO staffUserInfoDTO1=staffUserInfoMapper.findById(staffUserInfo.getId());
|
|
|
+ if (StringUtils.isNotBlank(staffUserInfoDTO1.getUserId())){
|
|
|
+ userId=staffUserInfoDTO1.getUserId();
|
|
|
+ }else {
|
|
|
+ userId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ }
|
|
|
+ UserDTO dto = new UserDTO();
|
|
|
+ dto.setId(userId);
|
|
|
+ dto.setName(staffUserInfo.getName());
|
|
|
+ dto.setLoginName(staffUserInfo.getName());
|
|
|
+ dto.setLoginFlag("1");
|
|
|
+ dto.setPassword(SecurityUtils.encryptPassword("123456"));
|
|
|
+ dto.setMobile(staffUserInfo.getMobilePhone());
|
|
|
+ dto.setTenantDTO(userDTO.getTenantDTO());
|
|
|
+ dto.setCompanyDTO(userDTO.getCompanyDTO());
|
|
|
+ OfficeDTO officeDTO = new OfficeDTO();
|
|
|
+ officeDTO.setId(staffUserInfo.getDepartment());
|
|
|
+ dto.setOfficeDTO(officeDTO);
|
|
|
+ dto.setManageOfficeIds(staffUserInfo.getManagerOffice());
|
|
|
+ dto.setPostDTOList(postDTOS);
|
|
|
+ dto.setRoleDTOList(roleDTOS);
|
|
|
+ SpringUtil.getBean(IUserApi.class).saveOrUpdate(dto);
|
|
|
+
|
|
|
+ staffUserInfo.setUserId(userId);
|
|
|
+
|
|
|
+ //如果是员工状态为试用的话,则往转正申请表中添加一条数据
|
|
|
+ if ("1".equals(staffUserInfo.getOnJobStatus())){
|
|
|
+ //先判断转正表中有没有数据
|
|
|
+ LambdaQueryWrapper<RegularApply> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(RegularApply::getInfoId,staffUserInfo.getId());
|
|
|
+ RegularApply regularApply = regularApplyMapper.selectOne(queryWrapper);
|
|
|
+ if (ObjectUtil.isEmpty(regularApply)){
|
|
|
+ RegularApply regularApply1 = new RegularApply();
|
|
|
+ regularApply1.setInfoId(staffUserInfo.getId());
|
|
|
+ regularApply1.setCreateById(staffUserInfo.getUserId());
|
|
|
+ regularApply1.setCreateTime(new Date());
|
|
|
+ regularApply1.setUpdateById(staffUserInfo.getUserId());
|
|
|
+ regularApply1.setUpdateTime(new Date());
|
|
|
+ regularApply1.setStatus("0");
|
|
|
+ regularApplyMapper.insert(regularApply1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(staffUserInfoDTO.getId())){
|
|
|
id=staffUserInfoDTO.getId();
|
|
|
staffUserInfoMapper.updateById(staffUserInfo);
|
|
@@ -208,9 +274,9 @@ public class StaffUserInfoService {
|
|
|
//获取id
|
|
|
id = UUID.randomUUID().toString().replace("-", "");
|
|
|
staffUserInfo.setId(id);
|
|
|
- staffUserInfo.setUserId(userId);
|
|
|
staffUserInfoMapper.insert(staffUserInfo);
|
|
|
}
|
|
|
+
|
|
|
if (ObjectUtils.isNotEmpty(staffUserInfoDTO)){
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
//承诺书
|
|
@@ -285,4 +351,108 @@ public class StaffUserInfoService {
|
|
|
staffUserInfoMapper.deleteById(id);
|
|
|
return "操作成功";
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询转正信息
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RegularApply findByApplyId(String id) {
|
|
|
+ RegularApply regularApply=staffUserInfoMapper.findByApplyId(id);
|
|
|
+ return regularApply;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存/修改转正信息
|
|
|
+ * @param regularApply
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RegularApply saveApplyForm(RegularApply regularApply) {
|
|
|
+ //获取当前登录人信息
|
|
|
+ UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
+ RegularApply apply = new RegularApply();
|
|
|
+ BeanUtils.copyProperties(regularApply,apply);
|
|
|
+ apply.setUpdateTime(new Date());
|
|
|
+ apply.setUpdateById(userDTO.getId());
|
|
|
+ if (StringUtils.isNotBlank(regularApply.getId())){
|
|
|
+ regularApplyMapper.updateById(apply);
|
|
|
+ }else {
|
|
|
+ regularApplyMapper.insert(apply);
|
|
|
+ }
|
|
|
+ RegularApply applyId = findByApplyId(regularApply.getId());
|
|
|
+ //查询入职表中的信息
|
|
|
+ StaffUserInfoDTO infoDTO = findById(applyId.getInfoId());
|
|
|
+ //判断是否通过
|
|
|
+ if (StringUtils.isNotBlank(regularApply.getIsPass()) ){
|
|
|
+ if (regularApply.getIsPass().equals("1")){
|
|
|
+ //不通过则去判断是否留用
|
|
|
+ if (StringUtils.isNotBlank(regularApply.getIsEmploy())){
|
|
|
+ //不通过也不留用同时状态为5 则将该员工账号冻结
|
|
|
+ if (regularApply.getIsPass().equals("1")&& regularApply.getIsEmploy().equals("1") && regularApply.getStatus().equals("5")){
|
|
|
+ UserDTO dto = new UserDTO();
|
|
|
+ dto.setLoginFlag("0");
|
|
|
+ dto.setId(infoDTO.getUserId());
|
|
|
+ SpringUtil.getBean(IUserApi.class).saveOrUpdate(dto);
|
|
|
+ }
|
|
|
+ if (regularApply.getIsPass().equals("1") && regularApply.getIsEmploy().equals("0") && regularApply.getStatus().equals("5")){
|
|
|
+ //不通过 留用 但发起人驳回的情况下获取当前登录人所属岗位是否是人事部 若是人事部则冻结账号
|
|
|
+ for (PostDTO postDTO : userDTO.getPostDTOList()) {
|
|
|
+ if ("人事部".equals(postDTO.getId()) && regularApply.getStatus().equals("5")){
|
|
|
+ UserDTO dto = new UserDTO();
|
|
|
+ dto.setLoginFlag("0");
|
|
|
+ dto.setId(infoDTO.getUserId());
|
|
|
+ SpringUtil.getBean(IUserApi.class).saveOrUpdate(dto);
|
|
|
+ break;
|
|
|
+ }else if ("分管领导".equals(postDTO.getId()) && regularApply.getStatus().equals("5")){
|
|
|
+ //否则的话则顺延一个月
|
|
|
+ if (regularApply.getIsPostpone().equals("0")){
|
|
|
+ StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
+ staffUserInfo.setId(applyId.getInfoId());
|
|
|
+ //获取到原本的试用期限
|
|
|
+ int parseInt = Integer.parseInt(infoDTO.getTimeLimit());
|
|
|
+ //顺延一个月
|
|
|
+ int limit = parseInt+1;
|
|
|
+ staffUserInfo.setTimeLimit(limit+"");
|
|
|
+ //修改员工信息
|
|
|
+ staffUserInfoMapper.updateById(staffUserInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (regularApply.getStatus().equals("5")){
|
|
|
+ //将员工状态改为正式
|
|
|
+ StaffUserInfo staffUserInfo = new StaffUserInfo();
|
|
|
+ staffUserInfo.setOnJobStatus("2");
|
|
|
+ staffUserInfo.setId(applyId.getInfoId());
|
|
|
+ staffUserInfoMapper.updateById(staffUserInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return apply;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id修改转正状态
|
|
|
+ * @param regularApply
|
|
|
+ */
|
|
|
+ public void updateStatusByApplyId(RegularApply regularApply) {
|
|
|
+ staffUserInfoMapper.updateStatusByApplyId(regularApply.getId(),regularApply.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取试用期的所有人员信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<StaffUserInfoDTO> getList() {
|
|
|
+ List<StaffUserInfoDTO> list=staffUserInfoMapper.getList();
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|