修改同步信息

This commit is contained in:
daihh
2022-11-04 15:19:57 +08:00
parent 053edae6a2
commit 443c6a3b0d
7 changed files with 45 additions and 6 deletions

View File

@@ -61,7 +61,7 @@ public class StartRunner implements ApplicationRunner {
mainOrgMap.put(org.getKid(),mainOrg.getId());//
}
//同步用户信息
//同步用户信息,2022/11/04同步用户学习时长
//查询出本地用户
List<MainUser> allUsers=mainService.findAll();
for(MainUser mainUser : allUsers) {
@@ -72,13 +72,23 @@ public class StartRunner implements ApplicationRunner {
String newId=mainOrgMap.get(oldUser.getOrgnizationId());
if(StringUtils.isBlank(newId)) {
log.error("未找到【"+oldUser.getKid()+"】对应的机构id,不更新用户");
log.error("本地未找到【"+oldUser.getKid()+"】对应的机构id,不更新用户");
}else {
mainUser.setSysDepartId(oldUser.getOrgnizationId());
mainUser.setCompanyId(oldUser.getCompanyId());
mainUser.setDepartId(newId);
mainUser.setLearningDuration(oldUser.getLearningDuration());
mainUser.setStatus(oldUser.getStatus());
if(oldUser.getIsDeleted()!=null) {
mainUser.setDeleted(oldUser.getIsDeleted()==0? false:true);
}
mainService.updateUser(mainUser);
}
}else {
//本地应该删除
log.error("原系统中无【"+oldUser.getKid()+"】对应的用户id,本地标识删除此用户");
mainService.deleteAccount(mainUser.getId());
}
}

View File

@@ -37,7 +37,7 @@ public class OldUser implements java.io.Serializable{
* 状态0临时1正常2停用
*/
@Column(name = "status", length = 3)
private String status;
private Integer status;
/**
* 企业ID
@@ -50,10 +50,14 @@ public class OldUser implements java.io.Serializable{
*/
@Column(name = "orgnization_id", length = 150)
private String orgnizationId;
/**用户学习时长*/
@Column(name = "learning_duration")
private Float learningDuration;
/**
* 删除标记0正常1已删除
*/
@Column(name = "is_deleted", length = 3)
private String isDeleted;
private Integer isDeleted;
}

View File

@@ -11,7 +11,6 @@ import com.xboe.basic.dao.OldUserDao;
import com.xboe.basic.entity.OldOrganization;
import com.xboe.basic.entity.OldUser;
import com.xboe.basic.service.IOldService;
import com.xboe.common.OrderCondition;
/**

View File

@@ -15,7 +15,10 @@ public interface MainAccountDao extends JpaRepository<MainAccount,String>{
@Modifying
@Query(value = "update MainAccount set deleted=true where id=?1")
// @Transactional(rollbackFor = Exception.class)
public Integer setDeleted(String id);
@Modifying
@Query(value = "update MainAccount set status=?1,deleted=?2 where id=?3")
public Integer updateStatusAndDeleted(Integer status,Boolean deleted,String id);
}

View File

@@ -64,6 +64,10 @@ public class MainUser extends IdEntity {
*/
@Column(name = "sass_id", length = 36)
private String sassId;
/**用户学习时长*/
@Column(name = "learning_duration")
private Float learningDuration;
/**
* 删除标识
@@ -71,6 +75,11 @@ public class MainUser extends IdEntity {
@Column(name="deleted",length = 1)
private Boolean deleted;
/**
* 用户的状态
*/
private Integer status;
public MainUser() {
}

View File

@@ -27,5 +27,11 @@ public interface IMainDbSyncService {
void update(MainOrganization mainOrg);
void updateUser(MainUser muser);
/**
* 把账号设置为已删除
* @param id
*/
void deleteAccount(String id);
}

View File

@@ -59,10 +59,18 @@ public class MainDbSyncServiceImpl implements IMainDbSyncService {
return userDao.findAll();
}
@Override
@Transactional("transactionManagerPrimary")
public void deleteAccount(String id) {
accountDao.setDeleted(id);
}
@Override
@Transactional("transactionManagerPrimary")
public void updateUser(MainUser muser) {
userDao.update(muser.getDepartId(),muser.getSysDepartId(),muser.getCompanyId(),muser.getId());
accountDao.updateStatusAndDeleted(muser.getStatus(),muser.getDeleted(), muser.getId());
}
}