|
@@ -6,12 +6,18 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
-
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.classes.ClassesApi;
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.classes.dto.ClassesDTO;
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.classes.dto.ClassesDTOO;
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.professional.ProfessionalApi;
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.professional.dto.ProfessionalDTO;
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.schooldept.SchoolDeptApi;
|
|
|
+import cn.iocoder.yudao.module.eve.api.data.schooldept.dto.SchoolDeptDTO;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
|
|
|
-
|
|
|
+import cn.iocoder.yudao.module.system.convert.dept.SysDeptConvert;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
|
|
|
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
|
|
@@ -44,7 +50,12 @@ public class DeptServiceImpl implements DeptService {
|
|
|
@Resource
|
|
|
private DeptMapper deptMapper;
|
|
|
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private ClassesApi classesApi;
|
|
|
+ @Resource
|
|
|
+ private ProfessionalApi professionalApi;
|
|
|
+ @Resource
|
|
|
+ private SchoolDeptApi schoolDeptApi;
|
|
|
|
|
|
@Override
|
|
|
@CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
|
|
@@ -164,6 +175,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @DataPermission(enable = false)
|
|
|
public List<DeptDO> getDeptList(Collection<Long> ids) {
|
|
|
if (CollUtil.isEmpty(ids)) {
|
|
|
return Collections.emptyList();
|
|
@@ -177,8 +189,15 @@ public class DeptServiceImpl implements DeptService {
|
|
|
list.sort(Comparator.comparing(DeptDO::getSort));
|
|
|
return list;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public List<DeptDO> getDeptListByCollege(Long collegeId,DeptListReqVO reqVO) {
|
|
|
+ List<DeptDO> list = deptMapper.selectList(reqVO);
|
|
|
+ list.sort(Comparator.comparing(DeptDO::getSort));
|
|
|
+ return list;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
+ @DataPermission(enable = false)
|
|
|
public List<DeptDO> getDeptListByDept(Long id) {
|
|
|
List<DeptDO> list = getChildDeptList(id);
|
|
|
list.sort(Comparator.comparing(DeptDO::getSort));
|
|
@@ -186,6 +205,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+
|
|
|
public List<DeptDO> getChildDeptList(Long id) {
|
|
|
List<DeptDO> children = new LinkedList<>();
|
|
|
// 遍历每一层
|
|
@@ -204,8 +224,15 @@ public class DeptServiceImpl implements DeptService {
|
|
|
return children;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
|
|
|
+ public Long getCollegeNum() {
|
|
|
+ List<DeptDO> collegeList = getCollegeListByGlutID(0L);
|
|
|
+ return (long)collegeList.size();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
+ @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
|
|
|
public Long getCollegeId(Long id) {
|
|
|
List<DeptDO> collegeList = getCollegeListByGlutID(id);
|
|
|
if(collegeList.isEmpty()){
|
|
@@ -215,6 +242,10 @@ public class DeptServiceImpl implements DeptService {
|
|
|
|
|
|
return findCollegeId(id,collegeIdSet);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
|
|
|
public Long findCollegeId(Long id,Set<Long> collegeIdSet) {
|
|
|
if(collegeIdSet.contains(id)){
|
|
|
return id;
|
|
@@ -228,11 +259,13 @@ public class DeptServiceImpl implements DeptService {
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
+ @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
|
|
|
public List<DeptDO> getCollegeListByGlutID(Long id) {
|
|
|
- return deptMapper.selectListByParentId(0L);
|
|
|
+ return deptMapper.selectListByParentIdAndCollege(0L);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @DataPermission(enable = false)
|
|
|
public List<DeptDO> getChildDeptListByParent(Long id) {
|
|
|
return deptMapper.selectListByParentId(id);
|
|
|
}
|
|
@@ -268,6 +301,94 @@ public class DeptServiceImpl implements DeptService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<DeptDO> updateSchoolDept() {
|
|
|
+ List<SchoolDeptDTO> schoolDeptList = schoolDeptApi.getList();
|
|
|
+ List<ClassesDTO> classesList = classesApi.getList();
|
|
|
+ List<ClassesDTOO> classesList2 = BeanUtils.toBean(classesList, ClassesDTOO.class);
|
|
|
+ List<ProfessionalDTO> professionalList = professionalApi.getList();
|
|
|
+ List<DeptDO> list = new ArrayList<>();
|
|
|
+ //学校单位作为一级
|
|
|
+ list = SysDeptConvert.INSTANCE.schoolDeptToSysDeptList(schoolDeptList);
|
|
|
+
|
|
|
+ deptMapper.insertBatch(list);
|
|
|
+ List<String> bsList = list.stream().map(DeptDO::getBs).collect(Collectors.toList());
|
|
|
+ List<DeptDO> deptList = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>().in(DeptDO::getBs, bsList));
|
|
|
+ Map<String, Long> deptMap = deptList.stream().collect(Collectors.toMap(DeptDO::getBs, DeptDO::getId));
|
|
|
+ //专业二级
|
|
|
+ list = SysDeptConvert.INSTANCE.professionalToDeptList(professionalList);
|
|
|
+ list.stream().filter(profession -> profession.getParentBs() != null).forEach(profession -> profession.setParentId(deptMap.get(profession.getParentBs())));
|
|
|
|
|
|
+ deptMapper.insertBatch(list);
|
|
|
+ List<String> bsList2 = list.stream().map(DeptDO::getBs).collect(Collectors.toList());
|
|
|
+ List<DeptDO> deptList2 = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>().in(DeptDO::getBs, bsList2));
|
|
|
+ Map<String, Long> deptMap2 = deptList2.stream().collect(Collectors.toMap(DeptDO::getUniqueBs, DeptDO::getId));
|
|
|
+ //年级三级
|
|
|
+ list = SysDeptConvert.INSTANCE.classesNjToToDeptList(classesList2);
|
|
|
+ list = list.stream()
|
|
|
+ .filter(profession -> profession.getParentBs() != null)
|
|
|
+ // 新增过滤条件,剔除2020级以前的班级
|
|
|
+ .filter(profession -> {
|
|
|
+ String bs = profession.getBs();
|
|
|
+ if (bs.matches("\\d{4}级")) { // 确保bs是以四位数字加"级"的形式开始
|
|
|
+ int classYear = Integer.parseInt(bs.substring(0, 4));
|
|
|
+ return classYear >= 2020;
|
|
|
+ }
|
|
|
+ return false; // 如果格式不匹配,默认保留该元素,或根据需求调整
|
|
|
+ })
|
|
|
+ .peek(profession -> {
|
|
|
+ String uniqueBs = profession.getUniqueBs();
|
|
|
+ String bs = profession.getBs();
|
|
|
+ int newLength = uniqueBs.length() - bs.length();
|
|
|
+ String parentUniqueBs = uniqueBs.substring(0, newLength);
|
|
|
+ Long parentId = deptMap2.get(parentUniqueBs);
|
|
|
+ if (parentId != null) {
|
|
|
+ profession.setParentId(parentId);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .filter(profession -> profession.getParentId() != 0L) // 过滤掉parentId为0的元素
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Set<String> seenUniqueBs = new HashSet<>();
|
|
|
+
|
|
|
+ list = list.stream()
|
|
|
+ .filter(profession -> profession.getParentBs() != null)
|
|
|
+ .filter(profession -> seenUniqueBs.add(profession.getUniqueBs()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ deptMapper.insertBatch(list);
|
|
|
+ List<String> bsList3 = list.stream().map(DeptDO::getBs).collect(Collectors.toList());
|
|
|
+ List<DeptDO> deptList3 = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>().in(DeptDO::getBs, bsList3));
|
|
|
+ Map<String, Long> deptMap3 = deptList3.stream().collect(Collectors.toMap(DeptDO::getUniqueBs, DeptDO::getId));
|
|
|
+ //班级四级
|
|
|
+ list = SysDeptConvert.INSTANCE.classesToToDeptList(classesList);
|
|
|
+ list = list = list.stream()
|
|
|
+ .filter(profession -> profession.getParentBs() != null)
|
|
|
+ // 新增过滤条件,剔除2020级以前的班级
|
|
|
+ .filter(profession -> {
|
|
|
+ String bs = profession.getParentBs();
|
|
|
+ if (bs.matches("\\d{4}级")) { // 确保bs是以四位数字加"级"的形式开始
|
|
|
+ int classYear = Integer.parseInt(bs.substring(0, 4));
|
|
|
+ return classYear >= 2020;
|
|
|
+ }
|
|
|
+ return false; // 如果格式不匹配,默认保留该元素,或根据需求调整
|
|
|
+ })
|
|
|
+ .peek(profession -> {
|
|
|
+ String uniqueBs = profession.getUniqueBs();
|
|
|
+ String bs = profession.getBs();
|
|
|
+ int newLength = uniqueBs.length() - bs.length();
|
|
|
+ String parentUniqueBs = uniqueBs.substring(0, newLength);
|
|
|
+ Long parentId = deptMap3.get(parentUniqueBs);
|
|
|
+ if (parentId != null) {
|
|
|
+ profession.setParentId(parentId);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .filter(profession -> profession.getParentId() != 0L) // 过滤掉parentId为0的元素
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ deptMapper.insertBatch(list);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
|
|
|
}
|