From 00b55a9c6baf2ef608b5992a25dac62f128ebd01 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 25 Oct 2022 10:05:13 +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=E5=8C=BA=E5=9F=9F=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 4 + .../service/impl/ResourceServiceImpl.java | 60 +++++++- .../resources/mapper/resource/ResourceDao.xml | 135 ++++++++++-------- 3 files changed, 138 insertions(+), 61 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index 5f1b7696..83ab710e 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -375,6 +375,7 @@ public class CensusController { @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "region", value = "所属区域id", paramType = "query", dataType = "String"), }) public Result selectApplyDeptDetailTypeCountList(@RequestParam Map params) { return new Result().ok(resourceService.selectApplyDeptDetailTypeCountList(params)); @@ -388,6 +389,7 @@ public class CensusController { @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "region", value = "所属区域id", paramType = "query", dataType = "String"), }) public void exportSelectApplyDeptDetailTypeCountList(@RequestParam Map params, HttpServletResponse response) throws IOException { ArrayList resultList = (ArrayList) resourceService.selectApplyDeptDetailTypeCountList(params); @@ -421,6 +423,7 @@ public class CensusController { @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "region", value = "所属区域id", paramType = "query", dataType = "String"), }) public Result selectDeptDetailTypeCountList(@RequestParam Map params) { return new Result().ok(resourceService.selectDeptDetailTypeCountList(params)); @@ -434,6 +437,7 @@ public class CensusController { @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "region", value = "所属区域id", paramType = "query", dataType = "String"), }) public void exportSelectDeptDetailTypeCountList(@RequestParam Map params, HttpServletResponse response) throws IOException { ArrayList resultList = (ArrayList) resourceService.selectDeptDetailTypeCountList(params); 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 b1a24ed6..582612c1 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 @@ -2040,7 +2040,36 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + ArrayList resultList = new ArrayList<>(); + Map countMap = new HashMap<>(); + typeCountListMap.forEach((k, v) -> { + HashMap map = new HashMap<>(); + map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + map.put("name", k); + v.forEach(item -> { + map.put(item.get("type").toString(), item.get("count")); + if (countMap.containsKey(item.get("type"))) { + countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); + } else { + countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); + } + }); + resultList.add(map); + }); + Integer total = 0; + for (Integer count : countMap.values()) { + total += count; + } + countMap.put("count", total); + HashMap count = new HashMap<>(); + count.put("name", "总计"); + count.putAll(countMap); + resultList.add(count); + return resultList; + } else if (params.containsKey("region") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("region").toString())) { // 查区域 List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); ArrayList resultList = new ArrayList<>(); @@ -2196,6 +2225,35 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); + Map>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + ArrayList resultList = new ArrayList<>(); + Map countMap = new HashMap<>(); + typeCountListMap.forEach((k, v) -> { + HashMap map = new HashMap<>(); + map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + map.put("name", k); + v.forEach(item -> { + map.put(item.get("type").toString(), item.get("count")); + if (countMap.containsKey(item.get("type"))) { + countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); + } else { + countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); + } + }); + resultList.add(map); + }); + Integer total = 0; + for (Integer count : countMap.values()) { + total += count; + } + countMap.put("count", total); + HashMap count = new HashMap<>(); + count.put("name", "总计"); + count.putAll(countMap); + resultList.add(count); + return resultList; } else { // 全部部门 List> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); Map>> typeCountListMap = // 市级部门 diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index a229dc7f..52f7ce5a 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1766,6 +1766,9 @@ AND tdr.type = #{type} + + AND sd.district = #{region} + AND SUBSTR(taa.create_date, 1, 10) BETWEEN #{startDate} AND #{endDate} @@ -1851,6 +1854,9 @@ AND sd.id = #{deptId} + + AND sd.district = #{region} + AND tdr.type = #{type} @@ -1960,7 +1966,8 @@ '青岛市大数据发展管理局' AS 'resourceDeptName', '会议室' AS 'type', tmb.create_date AS 'createDate', - CASE tmb.state WHEN 1 THEN '审核中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '审核中' END AS 'approveStatus', + CASE tmb.state WHEN 1 THEN '审核中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '审核中' END AS + 'approveStatus', '' AS 'applyNumber' FROM t_meetingroom_book tmb, @@ -2011,49 +2018,49 @@ @@ -2107,46 +2114,54 @@