|
@@ -1,28 +1,34 @@
|
|
|
package com.qdport.service.impl;
|
|
package com.qdport.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.qdport.enums.QDPortEnum;
|
|
import com.qdport.enums.QDPortEnum;
|
|
|
import com.qdport.modules.system.entity.SysDept;
|
|
import com.qdport.modules.system.entity.SysDept;
|
|
|
|
|
+import com.qdport.modules.system.mapper.SysDeptMapper;
|
|
|
import com.qdport.modules.system.service.SysDeptService;
|
|
import com.qdport.modules.system.service.SysDeptService;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
|
public class PolicySystemService {
|
|
public class PolicySystemService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private SysDeptService deptService;
|
|
private SysDeptService deptService;
|
|
|
|
|
|
|
|
- public Map<String, String> getDeptNameAndCompanyName(String deptId){
|
|
|
|
|
|
|
+ public Map<String, String> getDeptNameAndCompanyName(String deptId) {
|
|
|
Map<String, String> result = new HashMap<>();
|
|
Map<String, String> result = new HashMap<>();
|
|
|
SysDept dept = deptService.getById(deptId);
|
|
SysDept dept = deptService.getById(deptId);
|
|
|
result.put("deptName", dept.getName());
|
|
result.put("deptName", dept.getName());
|
|
|
result.put("deptId", dept.getId());
|
|
result.put("deptId", dept.getId());
|
|
|
if (QDPortEnum.SYS_DEPT_TYPE_DEPT.getValue().equals(dept.getDeptType().toString())) {
|
|
if (QDPortEnum.SYS_DEPT_TYPE_DEPT.getValue().equals(dept.getDeptType().toString())) {
|
|
|
Long pid = dept.getParentId();
|
|
Long pid = dept.getParentId();
|
|
|
- while (true){
|
|
|
|
|
|
|
+ while (true) {
|
|
|
SysDept pDept = deptService.getById(pid);
|
|
SysDept pDept = deptService.getById(pid);
|
|
|
if (QDPortEnum.SYS_DEPT_TYPE_COMPANY.getValue().equals(pDept.getDeptType().toString())) {
|
|
if (QDPortEnum.SYS_DEPT_TYPE_COMPANY.getValue().equals(pDept.getDeptType().toString())) {
|
|
|
result.put("companyName", pDept.getName());
|
|
result.put("companyName", pDept.getName());
|
|
@@ -37,4 +43,32 @@ public class PolicySystemService {
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public List<SysDept> getDeptListByType(Integer deptType) {
|
|
|
|
|
+ QueryWrapper<SysDept> deptWrapper = new QueryWrapper<>();
|
|
|
|
|
+ deptWrapper.eq("DEPT_TYPE", deptType);
|
|
|
|
|
+ deptWrapper.orderByAsc("PARENT_ID");
|
|
|
|
|
+ List<SysDept> list = deptService.list(deptWrapper);
|
|
|
|
|
+ return this.streamMethod(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<SysDept> streamMethod(List<SysDept> treeList) {
|
|
|
|
|
+ List<SysDept> list = (List) treeList.stream().filter((t) -> {
|
|
|
|
|
+ return t.getParentId() == 0L;
|
|
|
|
|
+ }).map((item) -> {
|
|
|
|
|
+ item.setChildren(this.streamGetChildren(item, treeList));
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<SysDept> streamGetChildren(SysDept tree, List<SysDept> treeList) {
|
|
|
|
|
+ List<SysDept> list = (List) treeList.stream().filter((t) -> {
|
|
|
|
|
+ return t.getParentId().equals(Long.valueOf(tree.getId()));
|
|
|
|
|
+ }).map((item) -> {
|
|
|
|
|
+ item.setChildren(this.streamGetChildren(item, treeList));
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|