From d245197684352edf0cf852be628177cc00c34862 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Fri, 28 Oct 2022 14:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E7=BB=9F=E8=AE=A1=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BC=81=E4=B8=9A=E9=83=A8=E9=97=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResourceServiceImpl.java | 77 ++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 1288feff..89302155 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -2134,6 +2134,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); List> resultList = getDeptTemp1(); resultList.addAll(getDeptTemp2()); + resultList.addAll(getDeptTemp4()); Map countMap = new HashMap<>(); Map>> typeCountListMap = // 市级部门 @@ -2169,12 +2170,12 @@ public class ResourceServiceImpl extends CrudServiceImpl>> typeCountListMap2 = // 会议室 - typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("99")).collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + Map>> typeCountListMap2 = // 企业部门 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("4")).collect(Collectors.groupingBy(m -> m.get("district").toString())); resultList = resultList.stream().map(index -> { - if (typeCountListMap2.keySet().contains(index.get("name").toString())) { // 该部门存在上架信息 - index.put("count", Integer.parseInt(index.get("count").toString()) + typeCountListMap2.get(index.get("name").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); - typeCountListMap2.get(index.get("name").toString()).stream().forEach(count -> { + if (typeCountListMap2.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap2.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap2.get(index.get("dept_id").toString()).stream().forEach(count -> { index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); if (countMap.containsKey(count.get("type"))) { countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); @@ -2182,15 +2183,32 @@ public class ResourceServiceImpl extends CrudServiceImpl> temp = typeCountListMap2.keySet().stream().map(index_ -> { + Map>> typeCountListMap3 = // 会议室 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("99")).collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap3.keySet().contains(index.get("name").toString())) { // 该部门存在上架信息 + index.put("count", Integer.parseInt(index.get("count").toString()) + typeCountListMap3.get(index.get("name").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap3.get(index.get("name").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + typeCountListMap3.remove(index.get("name").toString());// 去除 + } + return index; + }).collect(Collectors.toList()); + + if (!typeCountListMap3.isEmpty()) { // 仍然有会议室信息 + List> temp = typeCountListMap3.keySet().stream().map(index_ -> { HashMap map = new HashMap<>(); - typeCountListMap2.get(index_).stream().forEach(count -> { + typeCountListMap3.get(index_).stream().forEach(count -> { map.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); if (countMap.containsKey(count.get("type"))) { countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); @@ -2292,6 +2310,7 @@ public class ResourceServiceImpl extends CrudServiceImpl index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); List> resultList = getDeptTemp1(); resultList.addAll(getDeptTemp2()); + resultList.addAll(getDeptTemp4()); Map countMap = new HashMap<>(); resultList = resultList.stream().map(index -> { if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 @@ -2323,6 +2342,22 @@ public class ResourceServiceImpl extends CrudServiceImpl>> typeCountListMap2 = // 企业部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("4")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap2.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap2.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap2.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); Integer total = 0; for (Integer count : countMap.values()) { total += count; @@ -2387,6 +2422,30 @@ public class ResourceServiceImpl extends CrudServiceImpl> getDeptTemp4() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name`,type,pid,district FROM sys_dept WHERE type = 4 AND `name` != '访客部门' ORDER BY sys_dept.sort;"); + resultList = maps.stream().map(index -> { + HashMap map = new HashMap<>(); + map.put("count", 0); // + map.put("name", index.get("name").toString()); + map.put("dept_id", index.get("id").toString()); + map.put("yyzy", "0"); + map.put("znsf", "0"); + map.put("tcfw", "0"); + map.put("kfzj", "0"); + map.put("ywzj", "0"); + map.put("jcss", "0"); + map.put("zsk", "0"); + map.put("sjzy", "0"); + return map; + }).collect(Collectors.toList()); + return resultList; + } + @Override public Object selectCensusResourceTable(Map params) { int curPage = 1;