REQ-2960 重写泰州人员同步逻辑
This commit is contained in:
parent
a964753def
commit
918eb5102b
@ -1,33 +1,22 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.api.vo.profiles.WorkerProfileUpdateVo;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.PractitionerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.WorkerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.request.QueryPersonProfileByIdOrPhoneDto;
|
||||
import cn.axzo.basics.profiles.dto.request.WorkerUpdateDto;
|
||||
import cn.axzo.basics.profiles.dto.response.v2.PersonUpdateVO;
|
||||
import cn.axzo.riven.config.FeignConfiguration;
|
||||
import cn.axzo.riven.third.job.ThirdCreateUserJob;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.Profiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.axzo.riven.test.taizhou;
|
||||
|
||||
import cn.axzo.riven.third.job.ThirdCreateUserJob;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/27 10:58
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class ThirdCreateUserJobTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ThirdCreateUserJob thirdCreateUserJob;
|
||||
|
||||
@Test
|
||||
public void jobTest() throws Exception {
|
||||
|
||||
thirdCreateUserJob.execute(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,6 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
@ -40,9 +39,6 @@ public class TaiZhouProjectPersonJob extends IJobHandler {
|
||||
@Autowired
|
||||
TaiZhouService taiZhouService;
|
||||
|
||||
@Autowired
|
||||
private ThirdCreateUserJob thirdCreateUserJob;
|
||||
|
||||
@XxlJob("taiZhouProjectPersonJob")
|
||||
@Override
|
||||
public ReturnT<String> execute(String s) throws Exception {
|
||||
@ -91,7 +87,12 @@ public class TaiZhouProjectPersonJob extends IJobHandler {
|
||||
log.info("taiZhouProjectPersonJob 同步项目人员信息--项目ID:{},size:{}", x.getThirdProjectId(), thirdPersonList.size());
|
||||
|
||||
thirdPersonList.forEach(thirdPerson -> {
|
||||
taiZhouService.handlePerson(thirdPerson, x);
|
||||
try {
|
||||
taiZhouService.handlePerson(thirdPerson, x);
|
||||
} catch (Exception e) {
|
||||
log.error("同步泰州人员异常,异常泰州人员ID:{},泰州姓名:{}", thirdPerson.getThirdUniquePersonId(), thirdPerson.getThirdPersonName(), e);
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
log.info("taiZhouProjectPersonJob 同步项目人员信息--项目ID:{},size:0", x.getThirdProjectId());
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
package cn.axzo.riven.third.job;
|
||||
|
||||
import cn.axzo.riven.third.service.ThirdPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectPersonService;
|
||||
import cn.axzo.riven.third.service.ThirdProjectService;
|
||||
import cn.axzo.riven.third.taizhou.service.TaiZhouService;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Author: zhongpeng
|
||||
* Date: 2024/6/25 14:12
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ThirdCreateUserJob extends IJobHandler {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ThirdProjectPersonService thirdProjectPersonService;
|
||||
|
||||
@Autowired
|
||||
private ThirdProjectService thirdProjectService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPersonService thirdPersonService;
|
||||
|
||||
@Autowired
|
||||
private TaiZhouService taiZhouService;
|
||||
|
||||
|
||||
@XxlJob("thirdCreateUserJob")
|
||||
@Override
|
||||
public ReturnT<String> execute(String s) throws Exception {
|
||||
|
||||
log.info("thirdCreateUserJob start");
|
||||
|
||||
|
||||
log.info("thirdCreateUserJob end");
|
||||
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,24 @@
|
||||
package cn.axzo.riven.third.rpc;
|
||||
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.api.vo.profiles.PersonProfileUpdateVo;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.PractitionerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.basic.WorkerProfileDto;
|
||||
import cn.axzo.basics.profiles.dto.request.MergeAccountReq;
|
||||
import cn.axzo.basics.profiles.dto.request.PersonUpdateDto;
|
||||
import cn.axzo.basics.profiles.dto.request.QueryPersonProfileByIdOrPhoneDto;
|
||||
import cn.axzo.basics.profiles.dto.response.v2.PersonUpdateVO;
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.riven.third.entity.ThirdPerson;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -40,7 +47,7 @@ public class UserCenterRpc {
|
||||
return response.getData().getPersonProfile();
|
||||
} else {
|
||||
log.error("手机号创建普通工人异常code:{},message:{}", response.getCode(), response.getMsg());
|
||||
return null;
|
||||
throw new ServiceException("手机号创建普通工人异常 phone:" + phone);
|
||||
}
|
||||
|
||||
}
|
||||
@ -52,42 +59,91 @@ public class UserCenterRpc {
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public PersonProfileDto queryPersonByPhone(String phone) throws Exception {
|
||||
public PersonProfileDto queryPersonByPhone(String phone) {
|
||||
|
||||
CommonResponse<PractitionerProfileDto> response = userProfileServiceApi.getPractitionerProfileByPhone(phone);
|
||||
|
||||
if (response.getCode() == HttpStatus.SC_OK || response.getCode() == 404) {
|
||||
if (!Objects.isNull(response.getData())) {
|
||||
return response.getData().getPersonProfile();
|
||||
QueryPersonProfileByIdOrPhoneDto request = new QueryPersonProfileByIdOrPhoneDto();
|
||||
request.setPhones(new ArrayList<>());
|
||||
request.getPhones().add(phone);
|
||||
CommonResponse<List<PersonProfileDto>> response = userProfileServiceApi.findPersonProfileListByIdOrPhone(request);
|
||||
|
||||
if (response.getCode() == HttpStatus.SC_OK) {
|
||||
if (!CollectionUtils.isEmpty(response.getData())) {
|
||||
return response.getData().get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
log.error("手机号查询用户信息异常code:{},message:{}", response.getCode(), response.getMsg());
|
||||
throw new Exception("通过手机号查询用户异常 phone:"+ phone);
|
||||
throw new ServiceException("通过手机号查询用户异常 phone:" + phone);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUserName(ThirdPerson thirdPerson) throws Exception {
|
||||
public void updateUserName(ThirdPerson thirdPerson) {
|
||||
PersonUpdateVO vo = new PersonUpdateVO();
|
||||
vo.setPersonId(thirdPerson.getPersonId());
|
||||
vo.setRealName(thirdPerson.getThirdPersonName());
|
||||
CommonResponse<Object> commonResponse = userProfileServiceApi.updatePersonDetail(vo);
|
||||
if (!(commonResponse.getCode() == HttpStatus.SC_OK)) {
|
||||
throw new Exception("更新姓名异常" + thirdPerson.getPersonId());
|
||||
throw new ServiceException("更新姓名异常" + thirdPerson.getPersonId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新安心筑手机号
|
||||
* @param personId 安心筑PersonID
|
||||
* @param phone 新手机号
|
||||
*
|
||||
* @param personId 安心筑PersonID
|
||||
* @param phone 新手机号
|
||||
*/
|
||||
public void updateUserPhone(Long personId ,String phone){
|
||||
public void updateUserPhone(Long personId, String phone) {
|
||||
|
||||
//todo
|
||||
PersonProfileUpdateVo updateVo = new PersonProfileUpdateVo();
|
||||
updateVo.setId(personId);
|
||||
updateVo.setUpdate(new PersonUpdateDto());
|
||||
updateVo.getUpdate().setPhone(phone);
|
||||
CommonResponse<PersonProfileDto> response = userProfileServiceApi.putPersonProfile(updateVo);
|
||||
if (!(response.getCode() == HttpStatus.SC_OK)) {
|
||||
log.error("调用安心筑手机号更新异常code:{},message:{}", response.getCode(), response.getMsg());
|
||||
throw new ServiceException("更新安心筑人员personID:" + personId + " 的手机号phone:" + phone + " 失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public PersonProfileDto queryPersonByPersonId(Long personId) {
|
||||
|
||||
CommonResponse<PersonProfileDto> response = userProfileServiceApi.getPersonProfile(personId);
|
||||
|
||||
if (response.getCode() == HttpStatus.SC_OK || response.getCode() == 404) {
|
||||
if (!Objects.isNull(response.getData())) {
|
||||
return response.getData();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
log.error("安心筑personID查询用户信息异常code:{},message:{}", response.getCode(), response.getMsg());
|
||||
throw new ServiceException("通过personID查询用户异常 personId:" + personId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void mergeAccount(Long mainPersonId, Long disappearPersonId) {
|
||||
|
||||
MergeAccountReq req = new MergeAccountReq();
|
||||
req.setDestPersonId(mainPersonId);
|
||||
req.setSourcePersonId(disappearPersonId);
|
||||
CommonResponse<Boolean> response = userProfileServiceApi.mergeAccount(req);
|
||||
|
||||
if (response.getCode() == HttpStatus.SC_OK) {
|
||||
if (!response.getData()) {
|
||||
throw new ServiceException("安心筑合并账号异常:" + response.getMsg());
|
||||
}
|
||||
} else {
|
||||
log.error("安心筑合并账号异常code:{},message:{}", response.getCode(), response.getMsg());
|
||||
throw new ServiceException("安心筑合并账号异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.axzo.riven.third.taizhou.service.impl;
|
||||
|
||||
import cn.axzo.basics.profiles.common.enums.VerifyStatus;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.riven.client.common.enums.ThirdCodeEnum;
|
||||
import cn.axzo.riven.third.common.AesUtil;
|
||||
import cn.axzo.riven.third.common.enums.SyncTypeEnum;
|
||||
@ -273,84 +275,216 @@ public class TaiZhouServiceImpl implements TaiZhouService {
|
||||
.ne(ThirdPerson::getThirdUniquePersonId, thirdPerson.getThirdUniquePersonId())
|
||||
.list();
|
||||
|
||||
return CollectionUtils.isEmpty(list);
|
||||
return !CollectionUtils.isEmpty(list);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handlePerson(ThirdPerson thirdPerson, TaiZhouProject taiZhouProject) {
|
||||
|
||||
ThirdPerson db = queryThirdPerson(thirdPerson);
|
||||
|
||||
ThirdPerson oldThirdPerson = queryThirdPerson(thirdPerson);
|
||||
//如果数据库为空,则插入
|
||||
if (Objects.isNull(db)) {
|
||||
|
||||
if (Objects.isNull(oldThirdPerson)) {
|
||||
//数据入库
|
||||
thirdPersonDao.save(thirdPerson);
|
||||
|
||||
//检查泰州手机号是否重复
|
||||
if (checkRepeatPhone(thirdPerson)) {
|
||||
log.error("泰州人员ID:{},对应姓名:{} 手机号:{} 重复", thirdPerson.getThirdUniquePersonId(), thirdPerson.getThirdPersonName(), thirdPerson.getThirdPersonPhone());
|
||||
return;
|
||||
}
|
||||
|
||||
//项目开关检查
|
||||
if (createAccountCheck(thirdPerson, taiZhouProject)) {
|
||||
createUserOrSyncUser(thirdPerson);
|
||||
}
|
||||
|
||||
|
||||
//业务操作
|
||||
newDataHandle(thirdPerson, taiZhouProject);
|
||||
}
|
||||
//反之则更新
|
||||
else {
|
||||
//先更新
|
||||
//先更新数据,保持和泰州一致
|
||||
updateThirdPerson(thirdPerson);
|
||||
//姓名变更
|
||||
if (!db.getThirdPersonName().equals(thirdPerson.getThirdPersonName())) {
|
||||
log.error("泰州人员ID:{},姓名发生变化:{} -> {} 跳过处理", thirdPerson.getThirdUniquePersonId(), db.getThirdPersonName(), thirdPerson.getThirdPersonPhone());
|
||||
return;
|
||||
}
|
||||
//身份证变更
|
||||
if (!db.getThirdIdNumber().equals(thirdPerson.getThirdIdNumber())) {
|
||||
log.error("泰州人员ID:{},身份发生证变化:{} -> {} 跳过处理", thirdPerson.getThirdUniquePersonId(), db.getThirdPersonName(), thirdPerson.getThirdPersonPhone());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//如果没有绑定,直接使用新手机号绑定
|
||||
if (db.getPersonId() == 0L) {
|
||||
//项目开关检查
|
||||
if (createAccountCheck(thirdPerson, taiZhouProject)) {
|
||||
createUserOrSyncUser(thirdPerson);
|
||||
}
|
||||
}
|
||||
//如绑定过了,且手机号发生了变更
|
||||
else if (!db.getThirdPersonPhone().equals(thirdPerson.getThirdPersonPhone())) {
|
||||
log.warn("泰州人员ID:{},手机号发生变化:{} -> {} ", thirdPerson.getThirdUniquePersonId(), db.getThirdPersonPhone(), thirdPerson.getThirdPersonPhone());
|
||||
|
||||
PersonProfileDto personProfileDto = null;
|
||||
try {
|
||||
personProfileDto = userCenterRpc.queryPersonByPhone(thirdPerson.getThirdPersonPhone());
|
||||
} catch (Exception e) {
|
||||
log.error("通过手机号查询安心筑账号异常,结束操作",e);
|
||||
return ;
|
||||
}
|
||||
|
||||
//泰州数据绑定过了安心筑账号,但是变更了手机号,且新手机号没有在安心筑注册,则更新安心筑手机号
|
||||
if(Objects.isNull(personProfileDto)){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//数据已经绑定了,且手机号没有变更,不做处理
|
||||
else {
|
||||
log.info("泰州人员ID:{},手机号:{},安心筑personId:{}", thirdPerson.getThirdUniquePersonId(), thirdPerson.getThirdPersonPhone(), thirdPerson.getPersonId());
|
||||
}
|
||||
//业务操作
|
||||
updateDataHandle(thirdPerson, taiZhouProject, oldThirdPerson);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateDataHandle(ThirdPerson thirdPerson, TaiZhouProject taiZhouProject, ThirdPerson oldThirdPerson) {
|
||||
//业务前置检查,泰州同步关键信息不能变化,身份证,姓名不能有变化
|
||||
taiZhouSyncBasicPersonCheck(thirdPerson, oldThirdPerson);
|
||||
|
||||
//如果没有绑定,直接使用新手机号绑定
|
||||
if (oldThirdPerson.getPersonId() == 0L) {
|
||||
|
||||
newDataHandle(thirdPerson, taiZhouProject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//手机号没有变化,直接跳过处理
|
||||
if (oldThirdPerson.getThirdPersonPhone().equals(thirdPerson.getThirdPersonPhone())) {
|
||||
//数据已经绑定了,且手机号没有变更,不做处理
|
||||
log.info("泰州人员姓名:{},手机号:{},安心筑personId:{} 绑定过的信息,且信息未修改,不做处理", thirdPerson.getThirdPersonName(), thirdPerson.getThirdPersonPhone(), oldThirdPerson.getPersonId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//如果泰州数据已经绑定过了安心筑账号,且泰州手机号发生了变更
|
||||
log.warn("泰州人员:{},手机号发生变化:{} -> {} ", thirdPerson.getThirdPersonName(), oldThirdPerson.getThirdPersonPhone(), thirdPerson.getThirdPersonPhone());
|
||||
|
||||
//查询新手机在安心筑记录
|
||||
PersonProfileDto newPerson = userCenterRpc.queryPersonByPhone(thirdPerson.getThirdPersonPhone());
|
||||
|
||||
//查询当前泰州信息绑定安心筑人员的信息
|
||||
PersonProfileDto currentBindPerson = userCenterRpc.queryPersonByPersonId(oldThirdPerson.getPersonId());
|
||||
|
||||
if (Objects.isNull(currentBindPerson)) {
|
||||
throw new ServiceException("已绑定安心筑账号不存在,PersonID:" + oldThirdPerson.getPersonId());
|
||||
}
|
||||
|
||||
//泰州数据已经绑定过了安心筑账号,但是泰州变更了手机号,且新手机号没有在安心筑注册,则更新安心筑手机号为泰州手机号
|
||||
if (Objects.isNull(newPerson)) {
|
||||
|
||||
//如果泰州信息绑定的安心筑账号的现有手机号和泰州新手机号已经一致了,跳过处理
|
||||
if (currentBindPerson.getPhone().equals(thirdPerson.getThirdPersonPhone())) {
|
||||
log.info("泰州手机号变更后,新手机号和安心筑一致,无需处理");
|
||||
return;
|
||||
}
|
||||
//泰州新手机号与绑定的安心筑手机号不一致,且必须要泰州姓名身份证和安心筑一致,才可以覆盖安心筑的手机号
|
||||
if (comparePersonInfo(currentBindPerson, thirdPerson)) {
|
||||
log.info("泰州同步数据,开始覆盖安心筑手机号,personId:{}:originPhone:{},newPhone:{}", currentBindPerson.getId(), currentBindPerson.getPhone(), thirdPerson.getThirdPersonPhone());
|
||||
userCenterRpc.updateUserPhone(thirdPerson.getPersonId(), thirdPerson.getThirdPersonPhone());
|
||||
} else {
|
||||
log.error("泰州信息和安心筑信息不一致,泰州人员名称:{}", thirdPerson.getThirdPersonName());
|
||||
}
|
||||
}
|
||||
//泰州数据已经绑定过了安心筑账号,但是泰州变更了手机号,且新手机号在安心筑已经注册了
|
||||
else {
|
||||
|
||||
//新老关联账号都没有实名,则修改绑定关系
|
||||
if (VerifyStatus.VERIFY_SUCCESS != currentBindPerson.getVerification().getVerifyStatus() &&
|
||||
VerifyStatus.VERIFY_SUCCESS != newPerson.getVerification().getVerifyStatus()) {
|
||||
|
||||
taiZhouPersonIdRepeatBindCheck(newPerson.getId());
|
||||
thirdPerson.setPersonId(newPerson.getId());
|
||||
|
||||
//将新手机关了的安心筑账号ID更新到中间表中
|
||||
//新手机号必须有对应的工人角色(新手机号对应的安心筑账号是查询出来的,可能没有工人角色,需要补充)
|
||||
userCenterRpc.createNormalWorker(thirdPerson.getThirdPersonPhone());
|
||||
|
||||
thirdPersonDao.lambdaUpdate()
|
||||
.eq(ThirdPerson::getThirdCode, thirdPerson.getThirdCode())
|
||||
.eq(ThirdPerson::getThirdUniquePersonId, thirdPerson.getThirdUniquePersonId())
|
||||
.set(ThirdPerson::getPersonId, thirdPerson.getPersonId())
|
||||
.update();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//如果老的账号实名了,但是新的没有实名,合并安心筑账号账号
|
||||
if (VerifyStatus.VERIFY_SUCCESS == currentBindPerson.getVerification().getVerifyStatus() &&
|
||||
VerifyStatus.VERIFY_SUCCESS != newPerson.getVerification().getVerifyStatus()) {
|
||||
|
||||
taiZhouPersonIdRepeatBindCheck(newPerson.getId());
|
||||
|
||||
//合并账号前,验证用户信息确认泰州和安心筑实名账号是同一个人
|
||||
if (comparePersonInfo(currentBindPerson, thirdPerson)) {
|
||||
//合并账号
|
||||
userCenterRpc.mergeAccount(currentBindPerson.getId(), newPerson.getId());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//如果老的关联账号没有实名,新的账号实名了
|
||||
if (VerifyStatus.VERIFY_SUCCESS != currentBindPerson.getVerification().getVerifyStatus() &&
|
||||
VerifyStatus.VERIFY_SUCCESS == newPerson.getVerification().getVerifyStatus()) {
|
||||
taiZhouPersonIdRepeatBindCheck(newPerson.getId());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//不存在2个都是实名的情况,除非是2个人,如果是2个人,手机号必定不一样
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 新数据处理
|
||||
*
|
||||
* @param thirdPerson
|
||||
* @param taiZhouProject
|
||||
*/
|
||||
private void newDataHandle(ThirdPerson thirdPerson, TaiZhouProject taiZhouProject) {
|
||||
|
||||
//检查泰州手机号是否重复
|
||||
if (checkRepeatPhone(thirdPerson)) {
|
||||
throw new ServiceException("泰州人员:" + thirdPerson.getThirdPersonName() + " 与其他泰州人员手机号重复,手机号为:" + thirdPerson.getThirdPersonPhone());
|
||||
}
|
||||
//项目开关同步检查
|
||||
if (createAccountCheck(thirdPerson, taiZhouProject)) {
|
||||
createUserOrSyncUser(thirdPerson);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查Person是否已经在泰州用户中绑定过了
|
||||
*
|
||||
* @param personId
|
||||
*/
|
||||
private void taiZhouPersonIdRepeatBindCheck(Long personId) {
|
||||
|
||||
List<ThirdPerson> list = thirdPersonDao.lambdaQuery()
|
||||
.eq(ThirdPerson::getThirdCode, ThirdCodeEnum.TAI_ZHOU.getCode())
|
||||
.eq(ThirdPerson::getPersonId, personId)
|
||||
.list();
|
||||
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
throw new ServiceException("安心筑PersonID:" + personId + " 已经绑定了其他泰州信息,不能多次绑定:");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 台州同步基本用户信息check
|
||||
* 同一个泰州PersonID的身份证和姓名不能有变化
|
||||
*
|
||||
* @param thirdPerson
|
||||
* @param db
|
||||
*/
|
||||
private void taiZhouSyncBasicPersonCheck(ThirdPerson thirdPerson, ThirdPerson db) {
|
||||
//姓名变更
|
||||
if (!db.getThirdPersonName().equals(thirdPerson.getThirdPersonName())) {
|
||||
throw new ServiceException("泰州PersonID:" + thirdPerson.getThirdUniquePersonId() + "姓名发生变化:" + db.getThirdPersonName() + "->" + thirdPerson.getThirdPersonName());
|
||||
}
|
||||
//身份证变更
|
||||
if (!db.getThirdIdNumber().equals(thirdPerson.getThirdIdNumber())) {
|
||||
throw new ServiceException("泰州PersonID:" + thirdPerson.getThirdUniquePersonId() + "身份证发生变化:" + db.getThirdIdNumber() + "->" + thirdPerson.getThirdIdNumber());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用泰州手机号覆盖安心筑手机号之前,进行以下检查
|
||||
* 1:身份证前4后4比对。
|
||||
* 2:姓名要一致
|
||||
*
|
||||
* @param personProfileDto
|
||||
* @param thirdPerson
|
||||
* @return
|
||||
*/
|
||||
private boolean comparePersonInfo(PersonProfileDto personProfileDto, ThirdPerson thirdPerson) {
|
||||
|
||||
//姓名比对
|
||||
if (!personProfileDto.getRealName().equals(thirdPerson.getThirdPersonName())) {
|
||||
log.error("泰州人员姓名与安心筑人员姓名不一致:泰州:{}-安心筑:{}", personProfileDto.getRealName(), thirdPerson.getThirdPersonName());
|
||||
return false;
|
||||
}
|
||||
//身份证比对,安心筑是明文,泰州是前4后4
|
||||
if (!personProfileDto.getIdNumber().startsWith(thirdPerson.getThirdIdNumber().substring(0, 4))) {
|
||||
log.error("泰州人员姓名与安心筑人员身份证不一致:泰州:{}-安心筑:{}", personProfileDto.getIdNumber(), thirdPerson.getThirdIdNumber());
|
||||
return false;
|
||||
}
|
||||
if (!personProfileDto.getIdNumber().endsWith(thirdPerson.getThirdIdNumber().substring(thirdPerson.getThirdIdNumber().length() - 4))) {
|
||||
log.error("泰州人员姓名与安心筑人员姓名不一致:泰州:{}-安心筑:{}", personProfileDto.getIdNumber(), thirdPerson.getThirdIdNumber());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或者同步用户
|
||||
* 如果手机号对应的用户已经存在了,则直接获取用户,如果不存在,则创建用户
|
||||
@ -368,19 +502,16 @@ public class TaiZhouServiceImpl implements TaiZhouService {
|
||||
PersonProfileDto personProfileDto = userCenterRpc.createNormalWorker(thirdPerson.getThirdPersonPhone());
|
||||
|
||||
if (Objects.isNull(personProfileDto)) {
|
||||
log.error("创建用户失败,程序跳过处理,请人工处理,或者等待后续重试,失败手机号:{}", thirdPerson.getThirdPersonPhone());
|
||||
return;
|
||||
throw new ServiceException("泰州人员:" + thirdPerson.getThirdPersonName() + " 创建安心筑用户失败,程序跳过处理,请人工处理,或者等待后续重试,失败手机号:" + thirdPerson.getThirdPersonPhone());
|
||||
}
|
||||
thirdPerson.setPersonId(personProfileDto.getId());
|
||||
//先更新安心筑表中的姓名,在更新三方表的记录,顺序不能变
|
||||
if (personProfileDto.getRealName().contains("工友") || personProfileDto.getRealName().contains("工人")) {
|
||||
try {
|
||||
userCenterRpc.updateUserName(thirdPerson);
|
||||
} catch (Exception e) {
|
||||
log.error("更新安心筑姓名异常", e);
|
||||
}
|
||||
userCenterRpc.updateUserName(thirdPerson);
|
||||
}
|
||||
|
||||
taiZhouPersonIdRepeatBindCheck(personProfileDto.getId());
|
||||
|
||||
//更新安心筑关联ID
|
||||
thirdPersonDao.lambdaUpdate()
|
||||
.eq(ThirdPerson::getThirdCode, thirdPerson.getThirdCode())
|
||||
@ -401,7 +532,6 @@ public class TaiZhouServiceImpl implements TaiZhouService {
|
||||
.set(!Objects.isNull(thirdPerson.getThirdIdNumber()), ThirdPerson::getThirdIdNumber, thirdPerson.getThirdIdNumber())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdPersonFaceUrl()), ThirdPerson::getThirdPersonFaceUrl, thirdPerson.getThirdPersonFaceUrl())
|
||||
.set(!Objects.isNull(thirdPerson.getThirdSex()), ThirdPerson::getThirdSex, thirdPerson.getThirdSex())
|
||||
.set(!Objects.isNull(thirdPerson.getPersonId()), ThirdPerson::getPersonId, thirdPerson.getPersonId())
|
||||
.update();
|
||||
}
|
||||
|
||||
@ -436,7 +566,7 @@ public class TaiZhouServiceImpl implements TaiZhouService {
|
||||
*/
|
||||
public Boolean createAccountCheck(ThirdPerson thirdPerson, TaiZhouProject taiZhouProject) {
|
||||
|
||||
SyncTypeEnum syncTypeEnum = SyncTypeEnum.apply(taiZhouProject.getThirdProjectId());
|
||||
SyncTypeEnum syncTypeEnum = SyncTypeEnum.apply(taiZhouProject.getSyncType());
|
||||
//项目开启了同步普通工人
|
||||
if (SyncTypeEnum.SYNC_NORMAL == syncTypeEnum) {
|
||||
List<ThirdProjectPerson> projectPersonList = thirdProjectPersonDao.lambdaQuery()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user