|
@@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Anonymous;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
+import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
import com.ruoyi.common.enums.ExamType;
|
|
import com.ruoyi.common.enums.ExamType;
|
|
@@ -222,12 +223,39 @@ public class FrontSyMajorRelationController extends BaseController {
|
|
|
query.setExamType(ConstantUtil.getExamTypeData(examType));
|
|
query.setExamType(ConstantUtil.getExamTypeData(examType));
|
|
|
List<SyMajor> majorList = syMajorService.selectSyMajorList(query);
|
|
List<SyMajor> majorList = syMajorService.selectSyMajorList(query);
|
|
|
List<SyVocational> toList = new ArrayList<>();
|
|
List<SyVocational> toList = new ArrayList<>();
|
|
|
- majorList.forEach(major->{
|
|
|
|
|
- SyVocational syVocational=new SyVocational();
|
|
|
|
|
- BeanUtils.copyProperties(major,syVocational);
|
|
|
|
|
- toList.add(syVocational);
|
|
|
|
|
- });
|
|
|
|
|
- return AjaxResult.success(vocationalService.buildVocationalTreeSelect(toList));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
|
|
+ List<String> majorListByPlan = new ArrayList<>();
|
|
|
|
|
+ //湖南:计划中有的专业加入
|
|
|
|
|
+ if (null != loginUser){
|
|
|
|
|
+ String location = loginUser.getUser().getLocation();
|
|
|
|
|
+ if ("湖南".equals(location)){
|
|
|
|
|
+ majorListByPlan = syMajorService.selectMajorsByPlan(location).stream().map(major->major.getName()).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean isFilter = false;
|
|
|
|
|
+ for (SyMajor major : majorList) {
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(majorListByPlan) ) {
|
|
|
|
|
+ if (major.getLevel()==3&&!majorListByPlan.contains(major.getName())) {
|
|
|
|
|
+ isFilter = true;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ SyVocational syVocational = new SyVocational();
|
|
|
|
|
+ BeanUtils.copyProperties(major, syVocational);
|
|
|
|
|
+ toList.add(syVocational);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ SyVocational syVocational = new SyVocational();
|
|
|
|
|
+ BeanUtils.copyProperties(major, syVocational);
|
|
|
|
|
+ toList.add(syVocational);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<TreeSelectVocational> list = vocationalService.buildVocationalTreeSelect(toList);
|
|
|
|
|
+ if (isFilter){
|
|
|
|
|
+ //清除非第三级中children为空
|
|
|
|
|
+ list = filterEmptyChildren(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -274,4 +302,32 @@ public class FrontSyMajorRelationController extends BaseController {
|
|
|
|
|
|
|
|
return AjaxResult.success(resultList);
|
|
return AjaxResult.success(resultList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 清除列表中 level != 3 且 children 为空的节点
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<TreeSelectVocational> filterEmptyChildren(List<TreeSelectVocational> list) {
|
|
|
|
|
+ if (list == null) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ return list.stream()
|
|
|
|
|
+ .filter(node -> {
|
|
|
|
|
+ // 如果 level == 3,保留该节点
|
|
|
|
|
+ if (Integer.valueOf(3).equals(node.getLevel())) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果 level != 3,但有子节点,先递归处理子节点
|
|
|
|
|
+ if (node.getChildren() != null && !node.getChildren().isEmpty()) {
|
|
|
|
|
+ List<TreeSelectVocational> filteredChildren = filterEmptyChildren(node.getChildren());
|
|
|
|
|
+ node.setChildren(filteredChildren);
|
|
|
|
|
+
|
|
|
|
|
+ // 处理子节点后,如果还有子节点,则保留该节点
|
|
|
|
|
+ return !filteredChildren.isEmpty();
|
|
|
|
|
+ }
|
|
|
|
|
+ // level != 3 且没有子节点,过滤掉
|
|
|
|
|
+ return false;
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|