同步问题修复

This commit is contained in:
zhangchenbiao
2023-08-16 14:58:47 +08:00
parent 8a98d646b8
commit 7e5e060155
2 changed files with 24 additions and 4 deletions

View File

@@ -284,7 +284,13 @@
</select>
<select id="getUserListByDeptLeader" resultMap="BaseResultMap">
select user_id, leader_dept_ids from enterprise_user where leader_dept_ids like concat("%", #{regionId}, "%") and deleted = 0
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from
enterprise_user
where
leader_dept_ids like concat("%", #{regionId}, "%") and deleted = 0
</select>
<select id="getUserListByDeptLeaders" resultMap="BaseResultMap">

View File

@@ -242,7 +242,7 @@ public class EnterpriseSyncServiceImpl implements EnterpriseSyncService {
Multimap<String, String> leaderDeptMap = ArrayListMultimap.create();
RegionDO region = SysDepartmentDTO.convertRegionDO(departmentDetail, leaderDeptMap, parentRegionInfo);
regionDAO.batchInsertOrUpdate(Arrays.asList(region));
dealUserLeaderDept(leaderDeptMap);
dealUserLeaderDept(departmentDetail.getId(), leaderDeptMap);
break;
case DEPARTMENT_UPDATED:
if(param.getIsChangeParent()){
@@ -252,7 +252,7 @@ public class EnterpriseSyncServiceImpl implements EnterpriseSyncService {
Multimap<String, String> updateLeaderDeptMap = ArrayListMultimap.create();
RegionDO updateRegion = SysDepartmentDTO.convertRegionDO(departmentDetail, updateLeaderDeptMap);
regionDAO.batchInsertOrUpdate(Arrays.asList(updateRegion));
dealUserLeaderDept(updateLeaderDeptMap);
dealUserLeaderDept(departmentDetail.getId(), updateLeaderDeptMap);
break;
case DEPARTMENT_DELETED:
boolean leafNode = regionDAO.isLeafNode(departmentDetail.getId());
@@ -283,8 +283,22 @@ public class EnterpriseSyncServiceImpl implements EnterpriseSyncService {
* 处理用户负责部门信息
* @param leaderDeptMap
*/
public void dealUserLeaderDept(Multimap<String, String> leaderDeptMap){
public void dealUserLeaderDept(String deptId, Multimap<String, String> leaderDeptMap){
if(leaderDeptMap.isEmpty()){
//删除用户存在的部门主管
List<EnterpriseUserDO> userList = enterpriseUserDAO.getUserListByDeptLeader(deptId);
for (EnterpriseUserDO enterpriseUser : userList) {
String leaderDeptIds = enterpriseUser.getLeaderDeptIds();
List<String> existDeptIds = JSONObject.parseArray(leaderDeptIds).stream().map(String::valueOf).collect(Collectors.toList());
//取并集
existDeptIds.remove(deptId);
List<String> allDeptIds = existDeptIds.stream().distinct().collect(Collectors.toList());
if(CollectionUtils.isEmpty(allDeptIds)){
enterpriseUser.setIsLeader(Boolean.FALSE);
}
enterpriseUser.setLeaderDeptIds(JSONObject.toJSONString(allDeptIds));
}
enterpriseUserDAO.batchInsertOrUpdate(userList);
return;
}
List<String> userIds = leaderDeptMap.keys().stream().collect(Collectors.toList());