|
@@ -6,18 +6,12 @@ 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;
|
|
@@ -50,12 +44,7 @@ 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,
|
|
@@ -301,94 +290,4 @@ 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;
|
|
|
- }
|
|
|
-
|
|
|
}
|