修复钉钉同步时没有删除已经去掉的部门,同时获取部门属性列表时没有过滤删除的部门
This commit is contained in:
parent
c7f2afdbfa
commit
2c47896f3e
@ -57,4 +57,6 @@ public interface DepartmentsDao extends BaseMapper<DepartmentsEntity> {
|
||||
List<DepartmentsEntity> selectEntityByParentDepartmentIds(@Param("dIds") List<DepartmentsEntity> dIds);
|
||||
|
||||
DepartmentsEntity selectParentDepartmentByDepartmentId(String departmentId);
|
||||
|
||||
int delDepartments(@Param("list") List<DepartmentsEntity> departmentsEntities);
|
||||
}
|
||||
|
||||
@ -57,5 +57,9 @@ public interface DepartmentsService extends IService<DepartmentsEntity> {
|
||||
|
||||
//查找父级部门
|
||||
DepartmentsEntity selectParentDepartmentByDepartmentId(String departmentId);
|
||||
|
||||
List<DepartmentsEntity> selectAll();
|
||||
|
||||
int delDepartments(List<DepartmentsEntity> departmentsEntities);
|
||||
}
|
||||
|
||||
|
||||
@ -295,5 +295,15 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
|
||||
public DepartmentsEntity selectParentDepartmentByDepartmentId(String departmentId){
|
||||
return departmentsDao.selectParentDepartmentByDepartmentId(departmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentsEntity> selectAll(){
|
||||
return departmentsDao.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delDepartments(List<DepartmentsEntity> departmentsEntities){
|
||||
return departmentsDao.delDepartments(departmentsEntities);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.lz.common.utils.DateUtils;
|
||||
import com.lz.common.utils.DingTalkUtil;
|
||||
import com.lz.common.utils.R;
|
||||
import com.lz.modules.app.dao.StaffDao;
|
||||
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||
import com.lz.modules.app.entity.StaffEntity;
|
||||
import com.lz.modules.app.entity.StaffOccupationEntity;
|
||||
import com.lz.modules.app.entity.StaffSimpleInfo;
|
||||
@ -30,6 +31,7 @@ import com.lz.modules.third.entity.ThirdMsgSendRecord;
|
||||
import com.lz.modules.third.entity.WorkMsg;
|
||||
import com.lz.modules.third.service.ThirdAppConfigService;
|
||||
import com.lz.modules.third.service.ThirdMsgSendRecordService;
|
||||
import org.apache.commons.collections.map.CompositeMap;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -131,7 +133,12 @@ public class DingtalkBusiness {
|
||||
if(token != null && token.length() > 0){
|
||||
//获取所有的部门详情
|
||||
Map<String, DepartmentInfosBo> departmentInfosBos = dingTalkUtil.getDepartmentDetails(token, "1");
|
||||
|
||||
if(departmentInfosBos.size() > 0){
|
||||
//获取所有部门信息
|
||||
List<DepartmentsEntity> departmentsEntities = departmentsService.selectAll();
|
||||
Map<String, DepartmentsEntity> mapDeparts =
|
||||
departmentsEntities.stream().collect(Collectors.toMap(DepartmentsEntity::getDepartmentId, Function.identity(), (e, r) -> e));
|
||||
//更新数据库中的部门相关信息
|
||||
//departmentsService.updateDepartmentInfos(departmentInfosBos);
|
||||
//删除原有的对应关系下面在更新
|
||||
@ -140,6 +147,10 @@ public class DingtalkBusiness {
|
||||
staffOccupationService.updateAllOccupation();
|
||||
//获取飞书部门对应的用户详情
|
||||
for (String key : departmentInfosBos.keySet()) {
|
||||
if(mapDeparts.containsKey(key)){
|
||||
//部门存在
|
||||
mapDeparts.remove(key);
|
||||
}
|
||||
DepartmentInfosBo departmentInfo = departmentInfosBos.get(key);
|
||||
//获取部门用户详情
|
||||
List<DepartmentStaffBo> staffs = dingTalkUtil.getDepartmentStaffDetails(token, departmentInfo.getId());
|
||||
@ -178,6 +189,10 @@ public class DingtalkBusiness {
|
||||
DepartmentInfosBo departmentInfo = departmentInfosBos.get(key);
|
||||
departmentsService.updateDepartmentInfo(departmentInfo);
|
||||
}
|
||||
if(mapDeparts.size() > 0){//有需要删除的部门信息
|
||||
departmentsEntities = mapDeparts.values().stream().collect(Collectors.toList());
|
||||
departmentsService.delDepartments(departmentsEntities);
|
||||
}
|
||||
|
||||
}else{
|
||||
logger.info("部门信息为空");
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getDepartmentsByparentId" resultType="com.lz.modules.app.dto.DepartmentsDto">
|
||||
select id, department_id,department_parent_id,member_count,department_name from lz_departments where department_parent_id=#{parentId}
|
||||
select id, department_id,department_parent_id,member_count,department_name from lz_departments where department_parent_id=#{parentId} and is_delete=0
|
||||
</select>
|
||||
|
||||
<update id="updateDepartment">
|
||||
@ -179,5 +179,13 @@
|
||||
and is_delete=0 limit 1
|
||||
</select>
|
||||
|
||||
<update id="delDepartments">
|
||||
UPDATE lz_departments set is_delete = 1 WHERE id in(
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user