瀏覽代碼

入职与用户信息同步

sangwenwei 7 月之前
父節點
當前提交
8f0e10a8e2
共有 13 個文件被更改,包括 252 次插入8 次删除
  1. 5 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/factory/UserApiFallbackFactory.java
  2. 3 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/feign/IUserApi.java
  3. 20 0
      jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/controller/EnrollmentRegistrationController.java
  4. 2 0
      jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/domain/EnrollmentRegistration.java
  5. 13 0
      jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/mapper/EnrollmentRegistrationMapper.java
  6. 11 0
      jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/mapper/xml/EnrollmentRegistrationMapper.xml
  7. 60 7
      jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/service/EnrollmentRegistrationService.java
  8. 105 0
      jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/practice/register/service/RegistrationService.java
  9. 2 1
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/controller/UserController.java
  10. 5 0
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/feign/UserApiImpl.java
  11. 2 0
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/UserMapper.java
  12. 15 0
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/UserMapper.xml
  13. 9 0
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

+ 5 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/factory/UserApiFallbackFactory.java

@@ -241,6 +241,11 @@ public class UserApiFallbackFactory implements FallbackFactory <IUserApi> {
 
             }
 
+            @Override
+            public UserDTO getByMobile(String mobilePhone) {
+                return null;
+            }
+
         };
     }
 }

+ 3 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/feign/IUserApi.java

@@ -353,6 +353,9 @@ public interface IUserApi {
      */
     @PostMapping(value = BASE_URL + "/updateUserById")
     void updateUserById(@RequestBody UserDTO dto);
+
+    @GetMapping(value = BASE_URL + "/getByMobile")
+    UserDTO getByMobile(@RequestParam(value = "mobilePhone")String mobilePhone);
 }
 
 

+ 20 - 0
jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/controller/EnrollmentRegistrationController.java

@@ -209,6 +209,17 @@ public class EnrollmentRegistrationController {
     }
 
     /**
+     * 用户新增时对入职信息进行同步
+     * @param registration
+     * @return
+     */
+    @ApiLog(value = "用户新增时对入职信息进行同步", type = LogTypeEnum.SAVE)
+    @PostMapping("saveInfo")
+    public void saveInfo(@Valid @RequestBody EnrollmentRegistration registration) throws Exception {
+        service.saveInfo(registration);
+    }
+
+    /**
      * 保存个人信息完善登记信息
      * @param registration
      * @return
@@ -474,6 +485,15 @@ public class EnrollmentRegistrationController {
     }
 
     /**
+     * 用户表中删除时也删除入职信息
+     */
+    @ApiOperation(value = "删除")
+    @GetMapping("/delByUserId")
+    public void delByUserId(@RequestParam String id){
+        service.delByUserId(id);
+    }
+
+    /**
      * 查询
      * @param idCard
      * @return

+ 2 - 0
jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/domain/EnrollmentRegistration.java

@@ -79,4 +79,6 @@ public class EnrollmentRegistration extends BaseEntity {
     private String gsAccountHolderFront;
     @TableField(exist = false)
     private String gsAccountHolderOpposite;
+    @TableField(exist = false)
+    private String isPc; //用来判断是否是从电脑端发起的入职流程
 }

+ 13 - 0
jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/mapper/EnrollmentRegistrationMapper.java

@@ -56,4 +56,17 @@ public interface EnrollmentRegistrationMapper extends BaseMapper<EnrollmentRegis
      * @param id
      */
     void deleteByIdOnPhysic(@Param("id") String id);
+
+    /**
+     * 根据用户id查询数据
+     * @param userId
+     * @return
+     */
+    EnrollmentRegistration getByUserId(@Param("userId")String userId);
+
+    /**
+     * 根据用户id删除信息
+     * @param id
+     */
+    void delByUserId(@Param("id")String id);
 }

+ 11 - 0
jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/mapper/xml/EnrollmentRegistrationMapper.xml

@@ -122,4 +122,15 @@
 
         ) b;
     </select>
+
+    <select id="getByUserId" resultType="com.jeeplus.human.enrollment.enrollmentRegistration.domain.EnrollmentRegistration">
+        SELECT
+        <include refid="Base_Column_List"></include>
+        FROM `human_resources_enrollment_registration`  a
+        WHERE a.user_id = #{userId} and a.del_flag = '0'
+    </select>
+    <delete id="delByUserId">
+        UPDATE human_resources_enrollment_registration SET del_flag = '1'
+		WHERE user_id = #{id}
+    </delete>
 </mapper>

+ 60 - 7
jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/enrollment/enrollmentRegistration/service/EnrollmentRegistrationService.java

@@ -150,17 +150,18 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
             }
 
             //if (null == currentToken) {
+
                 //发起员工入职流程
                 Map map = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("员工入职");
-                String procDefId = map.get("id")+"";
+                String procDefId = map.get("id") + "";
 
                 report.setProcessDefinitionId(procDefId);
                 report.setProcessType("0");
                 mapper.insert(report);
 
-                Map<String ,Map<String,String >>  allMap = new HashMap<>();
+                Map<String, Map<String, String>> allMap = new HashMap<>();
 
-                String procDefKey = map.get("key")+"";
+                String procDefKey = map.get("key") + "";
                 String businessTable = "human_resources_enrollment_registration";
 
                 String businessId = id;
@@ -172,8 +173,10 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
                 String recordType = "";
 
                 Map<String, String> newMap = pingMap(procDefId, procDefKey, businessTable, businessId, title, assignee, recordType);
-                allMap.put("入职",newMap);
+                allMap.put("入职", newMap);
+            if (StringUtils.isBlank(reportData.getIsPc())) {
                 SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
+            }
             /*} else {
                 mapper.insert(report);
             }*/
@@ -249,12 +252,20 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
                 dto.setLoginName(report.getName());
                 dto.setLoginFlag("1");
                 dto.setMobile(report.getMobilePhone());
-                dto.setTenantDTO(userDTO.getTenantDTO());
-                dto.setCompanyDTO(userDTO.getCompanyDTO());
+                dto.setPhoto("");
+//                dto.setTenantDTO(userDTO.getTenantDTO());
+                //部门
                 OfficeDTO officeDTO = new OfficeDTO();
                 officeDTO.setId(report.getDepartment());
+                dto.setOfficeDTO(officeDTO);
                 //设置角色
                 OfficeDTO office = SpringUtil.getBean(IOfficeApi.class).getOfficeById(report.getDepartment());
+                //公司
+                OfficeDTO companyDto = new OfficeDTO();
+                companyDto.setId(office.getParent().getId());
+                dto.setCompanyDTO(companyDto);
+
+                dto.setNo(report.getMobilePhone());
 
                 String name = "兴光会计员工";
                 List <RoleDTO> roleIdList = new ArrayList<>();
@@ -295,7 +306,7 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
                     officeName = "综合管理公司";
                 }
                 dto.setRoleDTOList(roleIdList);
-                dto.setOfficeDTO(officeDTO);
+
 
                 SpringUtil.getBean ( IUserApi.class ).saveOrUpdate(dto);
 
@@ -481,6 +492,14 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
     }
 
     public String remove(String id) {
+        //先删除用户表中的信息
+        EnrollmentRegistration registration = mapper.getById(id);
+        if (registration != null){
+            UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByMobile(registration.getMobilePhone());
+            if (userDTO!=null){
+                SpringUtil.getBean(IUserApi.class).deleteById(userDTO.getId());
+            }
+        }
         // 删除基础信息表
         mapper.removeById(id);
         return "操作成功";
@@ -547,4 +566,38 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
     public List<String> getAllUserIdInSuccess() {
         return mapper.getAllUserIdInSuccess();
     }
+
+    /**
+     * 用户新增时对入职信息进行同步
+     * @param registration
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void saveInfo(EnrollmentRegistration registration) {
+        //现根据userId查询入职信息
+        if (StringUtils.isNotBlank(registration.getUserId())){
+            registration.setType("5");
+            registration.setOnJobStatus("2");
+            EnrollmentRegistration enrollmentRegistration=mapper.getByUserId(registration.getUserId());
+            if (enrollmentRegistration != null){
+                registration.setId(enrollmentRegistration.getId());
+                mapper.updateById(registration);
+            }else {
+                registration.setId(SnowFlake.getId());
+                mapper.insert(registration);
+            }
+
+
+        }
+
+
+    }
+
+    /**
+     * 根据用户id删除用户信息
+     * @param id
+     */
+    public void delByUserId(String id) {
+        mapper.delByUserId(id);
+    }
 }

+ 105 - 0
jeeplus-modules/jeeplus-human/src/main/java/com/jeeplus/human/practice/register/service/RegistrationService.java

@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jeeplus.common.SecurityUtils;
 import com.jeeplus.common.TokenProvider;
+import com.jeeplus.common.constant.CacheNames;
+import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.flowable.feign.IFlowableApi;
 import com.jeeplus.human.enrollment.enrollmentRegistration.service.EnrollmentRegistrationService;
@@ -27,6 +29,7 @@ import com.jeeplus.sys.feign.*;
 import com.jeeplus.sys.service.dto.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -60,6 +63,9 @@ public class RegistrationService extends ServiceImpl<InterRegistrationMapper, Re
     @Resource
     private EnrollmentRegistrationService enrollmentRegistrationService;
 
+    @Autowired
+    private RedisUtils redisUtils;
+
     public Integer findIdCardOnly(String idCard) throws Exception {
         QueryWrapper<Registration> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("id_card", idCard);
@@ -88,12 +94,19 @@ public class RegistrationService extends ServiceImpl<InterRegistrationMapper, Re
     }
 
     public String remove(String id) {
+        //根据手机号获取用户
+        Registration registration = mapper.getById(id);
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByMobile(registration.getMobilePhone());
+        if (userDTO != null){
+            SpringUtil.getBean(IUserApi.class).deleteById(userDTO.getId());
+        }
         //删除实习经验表的数据
         experienceMapper.deleteByRegisterId(id);
         //删除家庭成员表的数据
         familyMembersMapper.deleteByRegisterId(id);
         // 删除基础信息表
         mapper.removeById(id);
+
         return "操作成功";
     }
 
@@ -566,6 +579,54 @@ public class RegistrationService extends ServiceImpl<InterRegistrationMapper, Re
             });
         }
         mapper.updateById(report);
+
+        //根据用户手机号查询出用户信息
+        UserDTO userInfo = SpringUtil.getBean(IUserApi.class).getByMobile(report.getMobilePhone());
+        if (userInfo != null){
+            //往用户表中新增一条数据
+            UserDTO dto = new UserDTO();
+            dto.setId(userInfo.getId());
+            dto.setName(report.getName());
+            dto.setLoginName(report.getName());
+            dto.setMobile(report.getMobilePhone());
+            dto.setNo(report.getMobilePhone());
+            dto.setPhoto("");
+            //根据实习部门获取部门信息
+            OfficeDTO officeDTO = SpringUtil.getBean(IOfficeApi.class).getOfficeById(report.getPracticeOffice());
+            dto.setOfficeDTO(officeDTO);
+            OfficeDTO officeDTO1 = new OfficeDTO();
+            officeDTO1.setId(officeDTO.getParent().getId());
+            dto.setCompanyDTO(officeDTO1);
+            List <RoleDTO> roleIdList = new ArrayList<>();
+
+            if (null != officeDTO) {
+                Map<String,String> keyMap = new HashMap<>();
+                TenantDTO tenantDTO = new TenantDTO();
+                tenantDTO.setId(officeDTO.getTenantId());
+                dto.setTenantDTO(tenantDTO);
+                if (officeDTO.getTenantId().equals("10003")){
+                    keyMap.put("name", "兴光会计员工,共有权限(会计)");
+                    keyMap.put("tenantId", officeDTO.getTenantId());
+                    roleIdList = SpringUtil.getBean(IRoleApi.class).getRoleDTOByNameAndTenantId(keyMap);
+                }else if (officeDTO.getTenantId().equals("10004")) {
+                    keyMap.put("name", "中审员工,共有权限(中审)");
+                    keyMap.put("tenantId", officeDTO.getTenantId());
+                    roleIdList = SpringUtil.getBean(IRoleApi.class).getRoleDTOByNameAndTenantId(keyMap);
+                }else if (officeDTO.getTenantId().equals("10001")) {
+                    keyMap.put("name", "评估员工,共有权限(评估)");
+                    keyMap.put("tenantId", officeDTO.getTenantId());
+                    roleIdList = SpringUtil.getBean(IRoleApi.class).getRoleDTOByNameAndTenantId(keyMap);
+                }
+            } else {
+                TenantDTO tenantDTO = new TenantDTO();
+                tenantDTO.setId("10002");
+                dto.setTenantDTO(tenantDTO);
+            }
+            dto.setRoleDTOList(roleIdList);
+            SpringUtil.getBean ( IUserApi.class ).saveOrUpdate(dto);
+        }
+
+
     }
 
     /**
@@ -621,6 +682,50 @@ public class RegistrationService extends ServiceImpl<InterRegistrationMapper, Re
             });
         }
         mapper.insert(report);
+
+        //往用户表中新增一条数据
+        UserDTO dto = new UserDTO();
+        dto.setId(SnowFlake.getId());
+        dto.setName(report.getName());
+        dto.setPassword(SecurityUtils.encryptPassword("123456"));
+        dto.setLoginName(report.getName());
+        dto.setLoginFlag("1");
+        dto.setMobile(report.getMobilePhone());
+        dto.setNo(report.getMobilePhone());
+        dto.setPhoto("");
+        //根据实习部门获取部门信息
+        OfficeDTO officeDTO = SpringUtil.getBean(IOfficeApi.class).getOfficeById(report.getPracticeOffice());
+        dto.setOfficeDTO(officeDTO);
+        OfficeDTO officeDTO1 = new OfficeDTO();
+        officeDTO1.setId(officeDTO.getParent().getId());
+        dto.setCompanyDTO(officeDTO1);
+        List <RoleDTO> roleIdList = new ArrayList<>();
+
+        if (null != officeDTO) {
+            Map<String,String> keyMap = new HashMap<>();
+            TenantDTO tenantDTO = new TenantDTO();
+            tenantDTO.setId(officeDTO.getTenantId());
+            dto.setTenantDTO(tenantDTO);
+            if (officeDTO.getTenantId().equals("10003")){
+                keyMap.put("name", "兴光会计员工,共有权限(会计)");
+                keyMap.put("tenantId", officeDTO.getTenantId());
+                roleIdList = SpringUtil.getBean(IRoleApi.class).getRoleDTOByNameAndTenantId(keyMap);
+            }else if (officeDTO.getTenantId().equals("10004")) {
+                keyMap.put("name", "中审员工,共有权限(中审)");
+                keyMap.put("tenantId", officeDTO.getTenantId());
+                roleIdList = SpringUtil.getBean(IRoleApi.class).getRoleDTOByNameAndTenantId(keyMap);
+            }else if (officeDTO.getTenantId().equals("10001")) {
+                keyMap.put("name", "评估员工,共有权限(评估)");
+                keyMap.put("tenantId", officeDTO.getTenantId());
+                roleIdList = SpringUtil.getBean(IRoleApi.class).getRoleDTOByNameAndTenantId(keyMap);
+            }
+        } else {
+            TenantDTO tenantDTO = new TenantDTO();
+            tenantDTO.setId("10002");
+            dto.setTenantDTO(tenantDTO);
+        }
+        dto.setRoleDTOList(roleIdList);
+        SpringUtil.getBean ( IUserApi.class ).saveOrUpdate(dto);
     }
 
     /**

+ 2 - 1
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/controller/UserController.java

@@ -697,7 +697,8 @@ public class UserController {
         }
         // 保存用户信息
         userService.saveOrUpdate ( userDTO );
-        return ResponseEntity.ok ( "保存用户'" + userDTO.getLoginName ( ) + "'成功!" );
+//        return ResponseEntity.ok ( "保存用户'" + userDTO.getLoginName ( ) + "'成功!" );
+        return ResponseUtil.newInstance ( ).add("userId", userDTO.getId()).ok ("保存用户'" + userDTO.getLoginName ( ) + "'成功!");
     }
 
     /**

+ 5 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/feign/UserApiImpl.java

@@ -286,4 +286,9 @@ public class UserApiImpl implements IUserApi {
         userService.updateUserById(dto);
     }
 
+    @Override
+    public UserDTO getByMobile(String mobilePhone) {
+        return userService.getByMobile(mobilePhone);
+    }
+
 }

+ 2 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/UserMapper.java

@@ -290,4 +290,6 @@ public interface UserMapper extends BaseMapper <User> {
     List<UserDTO> getAllUserInfoNoTenId();
     @InterceptorIgnore(tenantLine = "true")
     void updateUserById(UserDTO dto);
+    @InterceptorIgnore(tenantLine = "true")
+    UserDTO getByMobile(@Param("mobilePhone")String mobilePhone);
 }

+ 15 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/UserMapper.xml

@@ -653,4 +653,19 @@ select a.id, a.company_id as "companyDTO.id", a.office_id as "officeDTO.id", a.l
         </if>
         where id =#{id} and del_flag = '0'
     </update>
+    <select id="getByMobile" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        select a.id, a.company_id as "companyDTO.id", a.office_id as "officeDTO.id", a.login_name as "loginName",
+		a.password,
+		a.no,
+		a.name,
+		a.email, a.phone,
+		a.mobile,
+		a.login_ip as "loginIp", a.login_date as "loginDate",
+		a.remarks,
+		a.login_flag, a.photo, a.qr_code, a.sign,
+		a.create_by_id as "createBy.id", a.create_time, a.update_by_id as "updateBy.id",
+		a.update_time
+		from sys_user a
+		where a.mobile = #{mobilePhone} and a.del_flag = '0'
+    </select>
 </mapper>

+ 9 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -752,4 +752,13 @@ public class UserService extends ServiceImpl <UserMapper, User> {
     public void updateUserById(UserDTO dto) {
         userMapper.updateUserById(dto);
     }
+
+    /**
+     * 根据手机号获取用户信息
+     * @param mobilePhone
+     * @return
+     */
+    public UserDTO getByMobile(String mobilePhone) {
+        return userMapper.getByMobile(mobilePhone);
+    }
 }