Browse Source

用户信息同步

sangwenwei 7 months ago
parent
commit
72b44c6e48

+ 63 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/domain/UserInfo.java

@@ -0,0 +1,63 @@
+package com.jeeplus.sys.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@Data
+public class UserInfo extends BaseEntity {
+
+    /**
+     * 员工入职日期
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    private Date inTime;
+
+    /**
+     * 用户id
+     */
+    private String userId;
+
+    private String name;                //姓名
+    private String sex;                 //性别
+    private String age;                 //年龄
+    private String birthday;            //出生日期
+    private String politicalOutlook;    //政治面貌
+    private String nativePlace;         //籍贯
+    private String nation;              //民族
+    private String maritalStatus;       //婚姻状况
+    private String mobilePhone;         //联系电话
+    private String idCard;              //身份证号码
+    private String homeAddress;         //家庭住址
+    private String permanentAddress;    //常住地址
+    private String graduatedFrom;       //毕业院校
+    private String speciality;          //专业
+    private String startTime;           //开始时间
+    private String endTime;             //毕业时间
+    private String education;           //学历
+    private String educationNature;     //学历性质
+    private String graduatedOrNot;      //是否毕业
+    private String englishLevel;        //英语等级
+    private String ncre;                //计算机等级
+    private String department;          //所属部门
+    private String remarks;             //备注
+    private String type;                //流程状态
+    private String procInsId;
+    private String processDefinitionId;
+    private String onJobStatus;       //在职状态
+    private String roleId;            //角色
+    private String postId;            //岗位
+    private String bankNumber;        //银行账号
+    private String email;               //邮箱
+    private String fundNumber;          //公积金账号
+    private String managerOffice;       //管理部门
+    private String timeLimit;   //试用期限
+
+
+
+}

+ 26 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/factory/StaffUserInfoApiFallbackFactory.java

@@ -0,0 +1,26 @@
+package com.jeeplus.sys.factory;
+
+import com.jeeplus.sys.domain.UserInfo;
+import com.jeeplus.sys.feign.IStaffUserInfoApi;
+import com.jeeplus.sys.feign.IUserApi;
+import com.jeeplus.sys.service.dto.StaffUserInfoDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class StaffUserInfoApiFallbackFactory implements FallbackFactory<IStaffUserInfoApi> {
+    @Override
+    public IStaffUserInfoApi create(Throwable throwable) {
+        log.error ( "用户服务调用失败:{}", throwable.getMessage ( ) );
+        throwable.printStackTrace ( );
+        return new IStaffUserInfoApi ( ) {
+
+            @Override
+            public void updateUser(UserInfo userDTO) {
+
+            }
+        };
+    }
+}

+ 26 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/feign/IStaffUserInfoApi.java

@@ -0,0 +1,26 @@
+package com.jeeplus.sys.feign;
+
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.sys.domain.UserInfo;
+import com.jeeplus.sys.factory.StaffUserInfoApiFallbackFactory;
+import com.jeeplus.sys.factory.UserApiFallbackFactory;
+import com.jeeplus.sys.service.dto.StaffUserInfoDTO;
+import com.jeeplus.sys.service.dto.UserDTO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+@FeignClient(contextId = "staffUserInfoApi", name = AppNameConstants.APP_JYPROJECT_MODULES, fallbackFactory = StaffUserInfoApiFallbackFactory.class)
+public interface IStaffUserInfoApi {
+
+    /**
+     * 更新用户
+     *
+     * @param userDTO
+     */
+    @PostMapping(value ="/employeeEntry/updateUser")
+    void updateUser(@RequestBody UserInfo userDTO);
+
+
+
+}

+ 149 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/service/dto/StaffUserInfoDTO.java

@@ -0,0 +1,149 @@
+package com.jeeplus.sys.service.dto;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class StaffUserInfoDTO extends BaseEntity {
+
+    /**
+     * 员工入职日期
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    private Date inTime;
+
+    /**
+     * 用户id
+     */
+    @ExcelIgnore
+    private String userId;
+    private String name;                //姓名
+    @ExcelIgnore
+    private String sex;                 //性别
+    @ExcelIgnore
+    private String age;                 //年龄
+    @ExcelIgnore
+    private String birthday;            //出生日期
+    @ExcelIgnore
+    private String politicalOutlook;    //政治面貌
+    private String nativePlace;         //籍贯
+    @ExcelIgnore
+    private String nation;              //民族
+    @ExcelIgnore
+    private String maritalStatus;       //婚姻状况
+    private String mobilePhone;         //联系电话
+    private String idCard;              //身份证号码
+    @ExcelIgnore
+    private String homeAddress;         //家庭住址
+    @ExcelIgnore
+    private String permanentAddress;    //常住地址
+    @ExcelIgnore
+    private String graduatedFrom;       //毕业院校
+    @ExcelIgnore
+    private String speciality;          //专业
+    @ExcelIgnore
+    private String startTime;           //开始时间
+    @ExcelIgnore
+    private String endTime;             //毕业时间
+    @ExcelIgnore
+    private String education;           //学历
+    @ExcelIgnore
+    private String educationNature;     //学历性质
+    @ExcelIgnore
+    private String graduatedOrNot;      //是否毕业
+    @ExcelIgnore
+    private String englishLevel;        //英语等级
+    @ExcelIgnore
+    private String ncre;                //计算机等级
+    private String department;          //所属部门
+    @ExcelIgnore
+    private String departmentName;
+    @ExcelIgnore
+    private String remarks;             //备注
+    @ExcelIgnore
+    private String type;                //流程状态
+    @ExcelIgnore
+    private String procInsId;
+    @ExcelIgnore
+    private String processDefinitionId;
+    @ExcelIgnore
+    private String onJobStatus;       //在职状态
+    @ExcelIgnore
+    private String roleId;            //角色
+    @ExcelIgnore
+    private String postId;            //岗位
+    @ExcelIgnore
+    private String bankNumber;        //银行账号
+    @ExcelIgnore
+    private String email;               //邮箱
+    @ExcelIgnore
+    private String fundNumber;          //公积金账号
+    @ExcelIgnore
+    private String managerOffice;       //管理部门
+
+
+
+
+    //部门
+    @ExcelIgnore
+    private String officeId;
+    @ExcelIgnore
+    private String officeName;
+    @ExcelIgnore
+    private String createName;
+    private Date createTime;
+
+
+    //员工状态
+    @ExcelIgnore
+
+    private String loginFlag;
+    private String flagName;
+
+    //创建时间
+    @ExcelIgnore
+    private String[] createDates;
+
+    //角色名称
+    @ExcelIgnore
+    private String roleName;
+    @ExcelIgnore
+    private List<String> roleIdList;
+    @ExcelIgnore
+    private List<String> postIdList;
+    @ExcelIgnore
+    private List<String> manageList;
+    @ExcelIgnore
+    private String taskId;
+
+    private String timeLimit;   //试用期限
+
+
+    //转正申请
+    private String procInsIdApply;
+    private String procDefIdApply;
+    private String taskIdApply;
+    private String applyId;
+    private String applyStatus;
+    //是否通过
+    private String isPass;
+    //是否留用
+    private String isEmploy;
+    //是否顺延
+    private String isPostpone;
+
+    //手签章url
+    private String handSignatureUrl;
+    //是否有手签章
+    private String isHandSignature;
+
+
+
+}

+ 1 - 1
jeeplus-modules/jeeplus-business/src/main/java/com/jeeplus/business/holiday/service/HolidayService.java

@@ -97,7 +97,7 @@ public class HolidayService {
         //获取当前登录人入职时间
         HolidayDTO dto=holidayMapper.findByUserId(userDTO.getId());
         //判断当前登录人是否有入职时间
-        if (ObjectUtils.isNotEmpty(dto)){
+        if (ObjectUtils.isNotEmpty(dto) && ObjectUtils.isNotEmpty(dto.getInTime())){
             Date date=dto.getInTime();
             LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
             LocalDate intime = LocalDate.of(localDate.getYear(), localDate.getMonth(), localDate.getDayOfMonth());

+ 9 - 0
jeeplus-modules/jeeplus-business/src/main/java/com/jeeplus/business/humanResources/controller/StaffUserInfoController.java

@@ -290,6 +290,15 @@ public class StaffUserInfoController {
     }
 
 
+    /**
+     * 添加用户信息
+     */
+    @ApiOperation(value = "添加用户信息")
+    @PostMapping(value = "/updateUser")
+    public void updateUser(@RequestBody StaffUserInfoDTO userInfoDTO) {
+        staffUserInfoService.updateUser(userInfoDTO);
+    }
+
 
 
 

+ 2 - 0
jeeplus-modules/jeeplus-business/src/main/java/com/jeeplus/business/humanResources/mapper/StaffUserInfoMapper.java

@@ -39,4 +39,6 @@ public interface StaffUserInfoMapper extends BaseMapper<StaffUserInfo> {
     List<WorkAttachmentInfo> findFiles(@Param("id") String id);
 
     List<StaffUserInfoDTO> getByPhone(@Param("mobilePhone") String mobilePhone);
+    //根据用户id查询用户信息
+    StaffUserInfoDTO getByUserId(@Param("userId") String userId);
 }

+ 5 - 1
jeeplus-modules/jeeplus-business/src/main/java/com/jeeplus/business/humanResources/mapper/xml/StaffUserInfoMapper.xml

@@ -262,7 +262,11 @@
             id
         from staff_user_info where mobile_phone = #{mobilePhone} and del_flag = '0'
     </select>
-
+    <select id="getByUserId" resultType="com.jeeplus.business.humanResources.service.dto.StaffUserInfoDTO">
+        select
+            id
+        from staff_user_info where user_id = #{userId} and del_flag = '0'
+    </select>
 
 
 </mapper>

+ 25 - 2
jeeplus-modules/jeeplus-business/src/main/java/com/jeeplus/business/humanResources/service/StaffUserInfoService.java

@@ -191,7 +191,7 @@ public class StaffUserInfoService {
         StaffUserInfo staffUserInfo = new StaffUserInfo();
 
         BeanUtils.copyProperties(staffUserInfoDTO,staffUserInfo);
-
+        staffUserInfo.setType("5");
         staffUserInfo.setUpdateById(userDTO.getId());
         staffUserInfo.setUpdateTime(new Date());
         String roleId="";
@@ -222,7 +222,7 @@ public class StaffUserInfoService {
         if (StringUtils.isNotBlank(staffUserInfo.getType())){
             if ("5".equals(staffUserInfo.getType())){
                 StaffUserInfoDTO staffUserInfoDTO1=staffUserInfoMapper.findById(staffUserInfo.getId());
-                if (StringUtils.isNotBlank(staffUserInfoDTO1.getUserId())){
+                if (ObjectUtils.isNotEmpty(staffUserInfoDTO1) && StringUtils.isNotBlank(staffUserInfoDTO1.getUserId())){
                     userId=staffUserInfoDTO1.getUserId();
                 }else {
 
@@ -619,4 +619,27 @@ public class StaffUserInfoService {
         }
         return false;
     }
+
+    /*8
+    添加用户信息
+     */
+    public void updateUser(StaffUserInfoDTO userInfoDTO) {
+        StaffUserInfo staffUserInfo = new StaffUserInfo();
+        userInfoDTO.setType("5");
+        if (ObjectUtils.isNotEmpty(userInfoDTO) && StringUtils.isNotBlank(userInfoDTO.getUserId())){
+            StaffUserInfoDTO infoDTO = staffUserInfoMapper.getByUserId(userInfoDTO.getUserId());
+            if (ObjectUtils.isNotEmpty(infoDTO)){
+                userInfoDTO.setId(infoDTO.getId());
+                BeanUtils.copyProperties(userInfoDTO,staffUserInfo);
+                staffUserInfoMapper.updateById(staffUserInfo);
+            }else {
+                String id = UUID.randomUUID().toString().replace("-", "");
+                staffUserInfo.setId(id);
+                BeanUtils.copyProperties(userInfoDTO,staffUserInfo);
+                staffUserInfoMapper.insert(staffUserInfo);
+            }
+        }
+
+
+    }
 }

+ 21 - 4
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -18,15 +18,14 @@ import com.jeeplus.common.constant.CacheNames;
 import com.jeeplus.common.constant.CommonConstants;
 import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.common.utils.RequestUtils;
-import com.jeeplus.sys.domain.Cert;
-import com.jeeplus.sys.domain.Office;
-import com.jeeplus.sys.domain.SysConfig;
-import com.jeeplus.sys.domain.User;
+import com.jeeplus.sys.domain.*;
+import com.jeeplus.sys.feign.IStaffUserInfoApi;
 import com.jeeplus.sys.feign.IUserApi;
 import com.jeeplus.sys.mapper.OfficeMapper;
 import com.jeeplus.sys.mapper.UserMapper;
 import com.jeeplus.sys.service.dto.CertDTO;
 import com.jeeplus.sys.service.dto.OfficeDTO;
+import com.jeeplus.sys.service.dto.StaffUserInfoDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.service.mapstruct.CertWrapper;
 import com.jeeplus.sys.service.mapstruct.UserWrapper;
@@ -394,6 +393,24 @@ public class UserService extends ServiceImpl <UserMapper, User> {
             //再次将人员信息存入到redis中
             redisUtils.set(CacheNames.USER_CACHE_USER_ALL_INFO,"user:cache:user:all:info",allUserInfo);
         }
+        if (StringUtils.isNotBlank(userDTO.getId())){
+            //将用户信息更新到入职表中
+            UserInfo staffUserInfoDTO = new UserInfo();
+            staffUserInfoDTO.setUserId(userDTO.getId());//用户id
+            staffUserInfoDTO.setName(userDTO.getName());
+            staffUserInfoDTO.setMobilePhone(userDTO.getMobile());
+            staffUserInfoDTO.setDepartment(userDTO.getOfficeDTO().getId());//所属部门
+            String roleIds = StringUtils.join(userDTO.getRoleIdList(), ",");
+            String postIds = StringUtils.join(userDTO.getPostIdList(), ",");
+            staffUserInfoDTO.setPostId(postIds); //岗位
+            staffUserInfoDTO.setManagerOffice(userDTO.getManageOfficeIds()); //管理部门
+            staffUserInfoDTO.setRoleId(roleIds); //角色
+            staffUserInfoDTO.setEmail(userDTO.getEmail());
+            staffUserInfoDTO.setCreateById(userDTO.getId());
+            staffUserInfoDTO.setUpdateById(userDTO.getId());
+            staffUserInfoDTO.setTenantId(userDTO.getTenantDTO().getId());
+            SpringUtil.getBean(IStaffUserInfoApi.class).updateUser(staffUserInfoDTO);
+        }
 
     }