|
@@ -1,66 +1,66 @@
|
|
|
-package com.sooka.sponest.data.utils;
|
|
|
-
|
|
|
-import com.ruoyi.common.core.utils.StringUtils;
|
|
|
-import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
-import com.ruoyi.system.api.RemoteDeptService;
|
|
|
-import com.ruoyi.system.api.domain.SysDept;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Component
|
|
|
-public class DeptLevelUtil {
|
|
|
-
|
|
|
- private static final Logger log = LoggerFactory.getLogger(DeptLevelUtil.class);
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RemoteDeptService remoteDeptService;
|
|
|
-
|
|
|
- public List<Map<String,Object>> getDeptLevel(List<Map<String,Object>> list,String deptId) {
|
|
|
- if (StringUtils.isEmpty(deptId)||"null".equals(deptId)){
|
|
|
- deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
|
|
|
- }
|
|
|
- List<SysDept> sysDeptList = remoteDeptService .selectChildrenCountyOrVillagesDeptListByDeptId(deptId).getData();
|
|
|
- if (StringUtils.isEmpty(list)){
|
|
|
- return null;
|
|
|
- }
|
|
|
- if (!list.get(0).containsKey("ancestors")||!list.get(0).containsKey("deptId")){
|
|
|
- log.error("入参没有key:'ancestors'或没有key:'deptId'");
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
- List<Map<String,Object>> mapList = new ArrayList<>();
|
|
|
- for (SysDept sysDept : sysDeptList){//部门
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- //map中增加key
|
|
|
- for (String key : list.get(0).keySet()) {
|
|
|
- if (!key.equals("ancestors")&&!key.equals("deptId")&&!key.equals("name")){
|
|
|
- map.put(key,0);
|
|
|
- }
|
|
|
- }
|
|
|
- for (Map<String,Object> ancestors : list){//资源数据
|
|
|
- if (ancestors.get("ancestors").toString().concat(",").concat(ancestors.get("deptId").toString()).contains(sysDept.getAncestors().concat(",").concat(sysDept.getDeptId().toString()))){
|
|
|
- for (String key : ancestors.keySet()) {
|
|
|
- if (!key.equals("ancestors")&&!key.equals("deptId")&&!key.equals("name")){
|
|
|
- map.put(key,new BigDecimal(map.get(key).toString()).add(new BigDecimal(ancestors.get(key).toString())));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (ancestors.containsKey("name")){
|
|
|
- map.put("name",ancestors.get("name"));
|
|
|
- }
|
|
|
- }
|
|
|
- map.put("deptId",sysDept.getDeptId());
|
|
|
- map.put("deptName",sysDept.getDeptName());
|
|
|
- map.put("deptType",sysDept.getDeptType());
|
|
|
- mapList.add(map);
|
|
|
- }
|
|
|
- return mapList;
|
|
|
- }
|
|
|
-}
|
|
|
+//package com.sooka.sponest.data.utils;
|
|
|
+//
|
|
|
+//import com.ruoyi.common.core.utils.StringUtils;
|
|
|
+//import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
+//import com.ruoyi.system.api.RemoteDeptService;
|
|
|
+//import com.ruoyi.system.api.domain.SysDept;
|
|
|
+//import org.slf4j.Logger;
|
|
|
+//import org.slf4j.LoggerFactory;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//import java.math.BigDecimal;
|
|
|
+//import java.util.ArrayList;
|
|
|
+//import java.util.HashMap;
|
|
|
+//import java.util.List;
|
|
|
+//import java.util.Map;
|
|
|
+//
|
|
|
+//@Component
|
|
|
+//public class DeptLevelUtil {
|
|
|
+//
|
|
|
+// private static final Logger log = LoggerFactory.getLogger(DeptLevelUtil.class);
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private RemoteDeptService remoteDeptService;
|
|
|
+//
|
|
|
+// public List<Map<String,Object>> getDeptLevel(List<Map<String,Object>> list,String deptId) {
|
|
|
+// if (StringUtils.isEmpty(deptId)||"null".equals(deptId)){
|
|
|
+// deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
|
|
|
+// }
|
|
|
+// List<SysDept> sysDeptList = remoteDeptService .selectChildrenCountyOrVillagesDeptListByDeptId(deptId).getData();
|
|
|
+// if (StringUtils.isEmpty(list)){
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// if (!list.get(0).containsKey("ancestors")||!list.get(0).containsKey("deptId")){
|
|
|
+// log.error("入参没有key:'ancestors'或没有key:'deptId'");
|
|
|
+// return new ArrayList<>();
|
|
|
+// }
|
|
|
+// List<Map<String,Object>> mapList = new ArrayList<>();
|
|
|
+// for (SysDept sysDept : sysDeptList){//部门
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// //map中增加key
|
|
|
+// for (String key : list.get(0).keySet()) {
|
|
|
+// if (!key.equals("ancestors")&&!key.equals("deptId")&&!key.equals("name")){
|
|
|
+// map.put(key,0);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// for (Map<String,Object> ancestors : list){//资源数据
|
|
|
+// if (ancestors.get("ancestors").toString().concat(",").concat(ancestors.get("deptId").toString()).contains(sysDept.getAncestors().concat(",").concat(sysDept.getDeptId().toString()))){
|
|
|
+// for (String key : ancestors.keySet()) {
|
|
|
+// if (!key.equals("ancestors")&&!key.equals("deptId")&&!key.equals("name")){
|
|
|
+// map.put(key,new BigDecimal(map.get(key).toString()).add(new BigDecimal(ancestors.get(key).toString())));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (ancestors.containsKey("name")){
|
|
|
+// map.put("name",ancestors.get("name"));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// map.put("deptId",sysDept.getDeptId());
|
|
|
+// map.put("deptName",sysDept.getDeptName());
|
|
|
+// map.put("deptType",sysDept.getDeptType());
|
|
|
+// mapList.add(map);
|
|
|
+// }
|
|
|
+// return mapList;
|
|
|
+// }
|
|
|
+//}
|