From 64e53c35351e20baa4b7dcfd5040131bbab5a20f Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Fri, 14 Oct 2022 14:57:46 +0800 Subject: [PATCH 01/20] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/device/TbDeviceDao.xml | 2 +- .../resources/mapper/resource/ResourceDao.xml | 63 ++++++++++--------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml b/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml index a82cda63..0815b9dd 100644 --- a/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml +++ b/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml @@ -18,7 +18,7 @@ SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, tdr.create_date AS createDate, - if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.instance_id AS applyNumber - FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date, + CASE WHEN (tdr.del_flag=0 OR tdr.del_flag=5) THEN '通过' WHEN tdr.del_flag=6 THEN '不通过' ELSE '审核中' END AS approveStatus, trma.instance_id AS applyNumber + FROM (SELECT IF(d.type='组件服务', a.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date, d.name FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND a.del_flag=0 @@ -1845,13 +1845,16 @@ WHERE 1=1 AND tdr.dept_id=sd.id - AND tdr.del_flag = 0 + AND tdr.del_flag in (0, 5) - AND tdr.del_flag in (2, 3) + AND tdr.del_flag not in (0, 1, 5, 6) + + + AND tdr.del_flag=6 - AND tdr.del_flag in (0, 2, 3) + AND tdr.del_flag != 1 @@ -1904,14 +1907,6 @@ AND su.dept_id = sd.id AND taa.resource_id = tdr.id AND dept.id = tdr.dept_id - AND taa.approve_status = #{approveStatus} @@ -1925,22 +1920,34 @@ AND SUBSTR(taa.create_date, 1, 10) BETWEEN #{startDate} AND #{endDate} + + UNION ALL - UNION ALL - - SELECT - tmb.dept AS 'deptName', - tm.`name` AS 'resourceName', - '青岛市大数据发展管理局' AS 'resourceDeptName', - '会议室' AS 'type', - tm.create_date AS 'createDate', - CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS 'approveStatus', - '' AS 'applyNumber' - FROM - t_meetingroom_book tmb, - t_meetingroom tm - WHERE - tmb.room_id = tm.id + SELECT + tmb.dept AS 'deptName', + tm.`name` AS 'resourceName', + '青岛市大数据发展管理局' AS 'resourceDeptName', + '会议室' AS 'type', + tm.create_date AS 'createDate', + CASE tmb.state WHEN 1 THEN '审核中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '审核中' END AS 'approveStatus', + '' AS 'applyNumber' + FROM + t_meetingroom_book tmb, + t_meetingroom tm + WHERE + tmb.room_id = tm.id + + + AND tmb.state=2 + + + AND tmb.state=3 + + + AND tmb.state not in (2, 3) + + + ORDER BY createDate DESC From 85d1e9eddf9afdcf48a797956ae05f1de2353d23 Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Fri, 14 Oct 2022 17:23:53 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87=E8=AF=A6=E6=83=85=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/device/service/Impl/TbDeviceApplyServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java index 05ee2fe3..4fc7d50e 100644 --- a/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java @@ -91,6 +91,10 @@ public class TbDeviceApplyServiceImpl extends CrudServiceImpl dtoList = tbDeviceApplyDao.queryList(params); List result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); + result.stream().forEach(it -> { + it.setTbDeviceDTO(tbDeviceService.get(it.getDeviceId())); + it.setAuditorName(sysUserService.get(it.getAuditor()).getRealName()); + }); return new PageData(result, dtoList.size()); } } From ce11e658fffbb75ffd2414bb52ff41d2c5e4a6ae Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 13:09:46 +0800 Subject: [PATCH 03/20] =?UTF-8?q?HIQDUCS-100=20=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResourceServiceImpl.java | 251 +++++++++++------- .../resources/mapper/resource/ResourceDao.xml | 17 +- 2 files changed, 172 insertions(+), 96 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 35b3c2ca..3050c8e8 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 @@ -478,34 +478,31 @@ public class ResourceServiceImpl extends CrudServiceImpl { - List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) - .sorted(Comparator.comparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - String total = (index.get("total") == null) ? "0" : index.get("total").toString(); - if (pingTOp_ <= 0) { - return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); - return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; - }).reversed() - ).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { + Map index = (Map) x; + int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); + String total = (index.get("total") == null) ? "0" : index.get("total").toString(); + if (pingTOp_ <= 0) { + return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); + return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; + }).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; case "ASC": // total 升序 ids = customThreadPool.submit(() -> { - List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) - .sorted(Comparator.comparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - String total = (index.get("total") == null) ? "0" : index.get("total").toString(); - if (pingTOp_ <= 0) { - return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); - return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; - })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { + Map index = (Map) x; + int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); + String total = (index.get("total") == null) ? "0" : index.get("total").toString(); + if (pingTOp_ <= 0) { + return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); + return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; + })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; @@ -513,32 +510,30 @@ public class ResourceServiceImpl extends CrudServiceImpl { - ResourceDTO index = (ResourceDTO) x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - long index_; - if (pinTop > 0) { - index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); - index_ = index_ % 1000; - } else { - index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); - } - return index_ == 0 ? -1 : index_; - }).reversed() - ).collect(Collectors.toList()); + ResourceDTO index = (ResourceDTO) x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + long index_; + if (pinTop > 0) { + index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); + index_ = index_ % 1000; + } else { + index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); + } + return index_ == 0 ? -1 : index_; + }).reversed()).collect(Collectors.toList()); } else { resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> { - ResourceDTO index = x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - long index_; - if (pinTop > 0) { - index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); - index_ = index_ % 1000; - } else { - index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); - } - return index_ == 0 ? -1 : index_; - }) - ).collect(Collectors.toList()); + ResourceDTO index = x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + long index_; + if (pinTop > 0) { + index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); + index_ = index_ % 1000; + } else { + index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); + } + return index_ == 0 ? -1 : index_; + })).collect(Collectors.toList()); } customThreadPool.shutdown(); } else { // 非总体评价排序时 @@ -693,11 +688,7 @@ public class ResourceServiceImpl extends CrudServiceImpl page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize")); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")) - .eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()) - .ne("type", "知识库") - .ne("type", "赋能案例") - .orderByDesc("create_date"); + queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).ne("type", "知识库").ne("type", "赋能案例").orderByDesc("create_date"); IPage resourceEntityIPage = resourceDao.selectPage(page, queryWrapper); IPage resourceDTOIPage = new Page<>(); resourceDTOIPage.setPages(resourceEntityIPage.getPages()); @@ -819,24 +810,23 @@ public class ResourceServiceImpl extends CrudServiceImpl>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); //区级要根据行政区划多加一层结构 - List tasks = - listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { - CompletableFuture task = CompletableFuture.runAsync(() -> { - HashMap map = new HashMap<>(); - map.put("type", item.getKey()); - Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); - map.put("total", integer); - item.getValue().forEach(item1 -> { - item1.remove("type"); - item1.remove("regionSort"); - }); - map.put("dataList", item.getValue()); - if (integer != 0) { - resultList.add(map); - } - }, executor); - return task; - }).collect(Collectors.toList()); + List tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { + CompletableFuture task = CompletableFuture.runAsync(() -> { + HashMap map = new HashMap<>(); + map.put("type", item.getKey()); + Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); + map.put("total", integer); + item.getValue().forEach(item1 -> { + item1.remove("type"); + item1.remove("regionSort"); + }); + map.put("dataList", item.getValue()); + if (integer != 0) { + resultList.add(map); + } + }, executor); + return task; + }).collect(Collectors.toList()); CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); Optional>> areaList = Optional.ofNullable(listMap.get("区级")); @@ -1115,8 +1105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("instance_id", instanceId) - .eq("approve_status", "通过"); + queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过"); List applicationEntities = tAbilityApplicationDao.selectList(queryWrapper); ArrayList cameraList = new ArrayList(); applicationEntities.forEach(index -> { @@ -1919,8 +1908,7 @@ 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>> typeCountListMap = // 市级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); + List> resultList = getDeptTemp1(); + resultList.addAll(getDeptTemp2()); 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); - }); + resultList = resultList.stream().map(index -> { + if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), count.get("count")); + 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()); + Map>> typeCountListMap1 = // 区级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap1.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()); +// 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; @@ -2098,6 +2119,56 @@ public class ResourceServiceImpl extends CrudServiceImpl> getDeptTemp1() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name`,type,pid,district FROM sys_dept WHERE type = 2 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; + } + + /** + * 获取区的初级构造 + * + * @return + */ + private List> getDeptTemp2() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_region WHERE tree_level = 3 AND leaf = 0 ORDER BY 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) { return resourceDao.selectCensusResourceTable(params); diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 5462c9cb..6d5d1d67 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -722,10 +722,10 @@ @@ -759,7 +759,8 @@ ( SELECT DISTINCT sd.id AS "deptId", - ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type" + ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS + "type" FROM sys_dept sd WHERE @@ -1790,6 +1791,9 @@ SELECT COUNT( tdr.id ) AS "count", sd.NAME AS "deptName", + sd.id AS "dept_id", + sd.type AS "deptType", + sd.district AS "district", (CASE tdr.type WHEN '应用资源' THEN 'yyzy' WHEN '智能算法' THEN 'znsf' @@ -1934,7 +1938,8 @@ '青岛市大数据发展管理局' AS 'resourceDeptName', '会议室' AS 'type', tm.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, From ad54ba9ac1782c40b2f80d0b2dba6d72c570785f Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 13:56:19 +0800 Subject: [PATCH 04/20] ... --- .../service/impl/ResourceServiceImpl.java | 127 ++++++++++-------- 1 file changed, 72 insertions(+), 55 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 3050c8e8..30ebf700 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 @@ -2056,67 +2056,84 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); - Map>> typeCountListMap = // 市级部门 - typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); - List> resultList = getDeptTemp1(); - resultList.addAll(getDeptTemp2()); - Map countMap = new HashMap<>(); - resultList = resultList.stream().map(index -> { - if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 - index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); - typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { - index.put(count.get("type").toString(), count.get("count")); - if (countMap.containsKey(count.get("type"))) { - countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + if (params.containsKey("deptId") && params.get("deptId") != null) { + List> 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(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + 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; } - return index; - }).collect(Collectors.toList()); - Map>> typeCountListMap1 = // 区级部门 - typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); - resultList = resultList.stream().map(index -> { - if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 - index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); - typeCountListMap1.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())); - } - }); + 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 = // 市级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); + List> resultList = getDeptTemp1(); + resultList.addAll(getDeptTemp2()); + Map countMap = new HashMap<>(); + resultList = resultList.stream().map(index -> { + if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), count.get("count")); + 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()); + Map>> typeCountListMap1 = // 区级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap1.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; } - return index; - }).collect(Collectors.toList()); -// 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; } - countMap.put("count", total); - HashMap count = new HashMap<>(); - count.put("name", "总计"); - count.putAll(countMap); - resultList.add(count); - return resultList; + } /** From f1c2cbc28e1295d5398287d644a024371dec81e8 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 14:07:07 +0800 Subject: [PATCH 05/20] ... --- .../modules/resource/service/impl/ResourceServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 30ebf700..cefc52f3 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 @@ -2056,7 +2056,7 @@ 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<>(); From b25309c1346d9ca8931f54a06431661479697048 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 14:15:23 +0800 Subject: [PATCH 06/20] =?UTF-8?q?=E5=B1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/resource/service/impl/ResourceServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cefc52f3..75a3949d 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 @@ -2056,7 +2056,7 @@ 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<>(); From abc082624d5ca1643a797386c9986f8ec487edb2 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 16:03:32 +0800 Subject: [PATCH 07/20] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResourceServiceImpl.java | 148 +++++++++++++++--- .../resources/mapper/resource/ResourceDao.xml | 9 +- 2 files changed, 129 insertions(+), 28 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 75a3949d..9c764ae6 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 @@ -2024,34 +2024,130 @@ 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())); - } + if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) { + List> 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); }); - resultList.add(map); - }); - Integer total = 0; - for (Integer count : countMap.values()) { - total += count; + 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> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + List> resultList = getDeptTemp1(); + resultList.addAll(getDeptTemp2()); + Map countMap = new HashMap<>(); + + Map>> typeCountListMap = // 市级部门 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), count.get("count")); + 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()); + Map>> typeCountListMap1 = // 区级部门 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap1.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()); + + Map>> typeCountListMap2 = // 会议室 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("99")).collect(Collectors.groupingBy(m -> m.get("deptName").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 -> { + 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())); + } + }); + typeCountListMap2.remove(typeCountListMap2.get(index.get("deptName").toString()));// 去除 + } + return index; + }).collect(Collectors.toList()); + + if (!typeCountListMap2.isEmpty()) { // 仍然有会议室信息 + List> temp = typeCountListMap2.keySet().stream().map(index_ -> { + HashMap map = new HashMap<>(); + typeCountListMap2.get(index_).stream().forEach(count -> { + map.put(count.get("type").toString(), Integer.parseInt(count.get("type").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())); + } + }); + map.put("name", index_); + map.put("dept_id", null); + 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"); + map.put("hys", "0"); + return map; + }).collect(Collectors.toList()); // 会议室的 + resultList.addAll(temp); + } + + 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; } - countMap.put("count", total); - HashMap count = new HashMap<>(); - count.put("name", "总计"); - count.putAll(countMap); - resultList.add(count); - return resultList; } @Override diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 1ead14f4..4083759c 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1719,6 +1719,9 @@ SELECT COUNT( taa.resource_id ) AS "count", sd.NAME AS "deptName", + sd.id AS "dept_id", + sd.type AS "deptType", + sd.district AS "district", ( CASE tdr.type @@ -1777,9 +1780,11 @@ UNION SELECT - - COUNT( id ) AS 'count' , + COUNT( id ) AS 'count', dept AS 'deptName', + NULL AS "dept_id", + 99 AS "deptType", + NULL AS "district", 'hys' AS 'type' FROM t_meetingroom_book tmb From c63bff7ef81fc76c4f988fd9d835f7e02680cf23 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 16:07:22 +0800 Subject: [PATCH 08/20] ... --- .../modules/resource/service/impl/ResourceServiceImpl.java | 1 - 1 file changed, 1 deletion(-) 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 9c764ae6..529e5ba0 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 @@ -2131,7 +2131,6 @@ public class ResourceServiceImpl extends CrudServiceImpl Date: Mon, 17 Oct 2022 16:18:10 +0800 Subject: [PATCH 09/20] npe --- .../modules/resource/service/impl/ResourceServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 529e5ba0..d4304988 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 @@ -2105,7 +2105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl Date: Mon, 17 Oct 2022 16:28:54 +0800 Subject: [PATCH 10/20] ... --- .../modules/resource/service/impl/ResourceServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d4304988..6bfa7dbe 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 @@ -2114,7 +2114,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> temp = typeCountListMap2.keySet().stream().map(index_ -> { HashMap map = new HashMap<>(); typeCountListMap2.get(index_).stream().forEach(count -> { - map.put(count.get("type").toString(), Integer.parseInt(count.get("type").toString())); + 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"))); } else { From 5b85df50108eb8838e3b214fd48a890cc0aaf4a4 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 17 Oct 2022 16:54:25 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E4=BC=9A=E8=AE=AE=E5=AE=A4=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/resource/service/impl/ResourceServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6bfa7dbe..f6668621 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 @@ -2105,7 +2105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl Date: Mon, 17 Oct 2022 17:56:53 +0800 Subject: [PATCH 12/20] npe --- .../src/main/resources/mapper/resourceCar/ResourceCarDao.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml index 55fe4beb..e87e1c28 100644 --- a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml @@ -84,7 +84,7 @@ From 020a32519add692d8635720ab529e9326467c4bc Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 11:18:11 +0800 Subject: [PATCH 15/20] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E7=BB=9F=E8=AE=A1=20?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 127 +++++++++++++++++- ...lectApplyDeptDetailTypeCountListExcel.java | 112 +++++++++++++++ 2 files changed, 234 insertions(+), 5 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java 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 c65e18f7..c89ad213 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 @@ -9,6 +9,7 @@ import io.renren.common.annotation.LogOperation; import io.renren.common.utils.Result; import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.resource.dao.ResourceDao; +import io.renren.modules.resource.excel.census.SelectApplyDeptDetailTypeCountListExcel; import io.renren.modules.resource.excel.census.SelectDeptDetailTypeCountListExcel; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; @@ -385,8 +386,25 @@ public class CensusController { @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), }) - public void exportSelectApplyDeptDetailTypeCountList(@RequestParam Map params) { - // TODO 导出按照部门、能力类型、组件类型统计能力使用情况 + public void exportSelectApplyDeptDetailTypeCountList(@RequestParam Map params, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectApplyDeptDetailTypeCountList(params); + List date = resultList.stream().map(index -> { + SelectApplyDeptDetailTypeCountListExcel temp = new SelectApplyDeptDetailTypeCountListExcel( + index.getOrDefault("name", "").toString(), + Integer.valueOf(index.getOrDefault("znsf", "0").toString()), + Integer.valueOf(index.getOrDefault("tcfw", "0").toString()), + Integer.valueOf(index.getOrDefault("kfzj", "0").toString()), + Integer.valueOf(index.getOrDefault("ywzy", "0").toString()), + Integer.valueOf(index.getOrDefault("yyzy", "0").toString()), + Integer.valueOf(index.getOrDefault("hys", "0").toString()), + Integer.valueOf(index.getOrDefault("count", "0").toString())); + return temp; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力使用情况", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), SelectApplyDeptDetailTypeCountListExcel.class).sheet("使用情况").doWrite(date); } @GetMapping("/selectDeptDetailTypeCountList") @@ -424,12 +442,11 @@ public class CensusController { temp.setYyzy(Integer.valueOf(index.getOrDefault("yyzy", "0").toString())); return temp; }).collect(Collectors.toList()); - // TODO 导出按照部门、能力类型、组件类型统计能力上架情况 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("导出按照部门_能力类型_组件类型统计能力上架情况", "UTF-8").replaceAll("\\+", "%20"); + String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力上架情况", "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class).sheet("数据").doWrite(date); + EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class).sheet("上架情况").doWrite(date); } @GetMapping("/selectCensusResourceTable") @@ -446,6 +463,54 @@ public class CensusController { return new Result().ok(resourceService.selectCensusResourceTable(params)); } + @GetMapping("/exportSelectCensusResourceTable") + @ApiOperation("查询部门上架资源及审批结果详细信息") + @LogOperation("查询部门上架资源及审批结果详细信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectCensusResourceTable(@RequestParam Map params, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectCensusResourceTable(params); + List> date = resultList.stream().map(index -> { + List data = new ArrayList<>(); + data.add(index.getOrDefault("deptName", "").toString()); + data.add(index.getOrDefault("type", "").toString()); + data.add(index.getOrDefault("resourceName", "").toString()); + data.add(index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("approveStatus", "").toString()); + return data; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("部门上架资源及审批结果详细信息", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead()).sheet("上架情况").doWrite(date); + } + + private List> exportSelectCensusResourceTableHead() { + List> list = new ArrayList<>(); + List head0 = new ArrayList<>(); + head0.add("上架部门"); + List head1 = new ArrayList<>(); + head0.add("类型"); + List head2 = new ArrayList<>(); + head0.add("资源名称"); + List head3 = new ArrayList<>(); + head0.add("日期"); + List head4 = new ArrayList<>(); + head0.add("状态"); + list.add(head0); + list.add(head1); + list.add(head2); + list.add(head3); + list.add(head4); + return list; + } + @GetMapping("/selectCensusApplyTable") @ApiOperation("查询部门申请资源及审批结果详细信息") @LogOperation("查询部门申请资源及审批结果详细信息") @@ -460,4 +525,56 @@ public class CensusController { return new Result().ok(resourceService.selectCensusApplyTable(params)); } + @GetMapping("/exportSelectCensusApplyTable") + @ApiOperation("导出查询部门申请资源及审批结果详细信息") + @LogOperation("导出查询部门申请资源及审批结果详细信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectCensusApplyTable(@RequestParam Map params, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectCensusApplyTable(params); + List> date = resultList.stream().map(index -> { + List data = new ArrayList<>(); + data.add(index.getOrDefault("resourceDeptName", "").toString()); + data.add(index.getOrDefault("resourceName", "").toString()); + data.add(index.getOrDefault("type", "").toString()); + data.add(index.getOrDefault("deptName", "").toString()); + data.add(index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("approveStatus", "").toString()); + return data; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("部门申请资源及审批结果详细信息", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusApplyTableHead()).sheet("申请情况").doWrite(date); + } + + private List> exportSelectCensusApplyTableHead() { + List> list = new ArrayList<>(); + List head0 = new ArrayList<>(); + head0.add("提供部门"); + List head1 = new ArrayList<>(); + head0.add("资源名称"); + List head2 = new ArrayList<>(); + head0.add("类型"); + List head3 = new ArrayList<>(); + head0.add("申请部门"); + List head4 = new ArrayList<>(); + head0.add("日期"); + List head5 = new ArrayList<>(); + head0.add("状态"); + list.add(head0); + list.add(head1); + list.add(head2); + list.add(head3); + list.add(head4); + list.add(head5); + return list; + } + } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java new file mode 100644 index 00000000..5c6e1208 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java @@ -0,0 +1,112 @@ +package io.renren.modules.resource.excel.census; + +import com.alibaba.excel.annotation.ExcelProperty; + +import java.util.Objects; + +public class SelectApplyDeptDetailTypeCountListExcel { + @ExcelProperty({"申请部门"}) + private String name; + @ExcelProperty({"组件", "智能算法"}) + private Integer znsf; + @ExcelProperty({"组件", "图层服务"}) + private Integer tcfw; + @ExcelProperty({"组件", "通用开发组件"}) + private Integer kfzj; + @ExcelProperty({"组件", "业务能力组件"}) + private Integer ywzj; + @ExcelProperty({"应用资源"}) + private Integer yyzy; + @ExcelProperty({"会议室"}) + private Integer hys; + @ExcelProperty({"总计"}) + private Integer count; + + public SelectApplyDeptDetailTypeCountListExcel(String name, Integer znsf, Integer tcfw, Integer kfzj, Integer ywzj, Integer yyzy, Integer hys, Integer count) { + this.name = name; + this.znsf = znsf; + this.tcfw = tcfw; + this.kfzj = kfzj; + this.ywzj = ywzj; + this.yyzy = yyzy; + this.hys = hys; + this.count = count; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getZnsf() { + return znsf; + } + + public void setZnsf(Integer znsf) { + this.znsf = znsf; + } + + public Integer getTcfw() { + return tcfw; + } + + public void setTcfw(Integer tcfw) { + this.tcfw = tcfw; + } + + public Integer getKfzj() { + return kfzj; + } + + public void setKfzj(Integer kfzj) { + this.kfzj = kfzj; + } + + public Integer getYwzj() { + return ywzj; + } + + public void setYwzj(Integer ywzj) { + this.ywzj = ywzj; + } + + public Integer getYyzy() { + return yyzy; + } + + public void setYyzy(Integer yyzy) { + this.yyzy = yyzy; + } + + public Integer getHys() { + return hys; + } + + public void setHys(Integer hys) { + this.hys = hys; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SelectApplyDeptDetailTypeCountListExcel that = (SelectApplyDeptDetailTypeCountListExcel) o; + return name.equals(that.name) && znsf.equals(that.znsf) && tcfw.equals(that.tcfw) && kfzj.equals(that.kfzj) && ywzj.equals(that.ywzj) && yyzy.equals(that.yyzy) && hys.equals(that.hys) && count.equals(that.count); + } + + @Override + public int hashCode() { + return Objects.hash(name, znsf, tcfw, kfzj, ywzj, yyzy, hys, count); + } +} From fa94eb77f3951df21996d10152ac43a85b80fa23 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 11:31:31 +0800 Subject: [PATCH 16/20] ... --- .../common/controller/CensusController.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 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 c89ad213..23e2d022 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 @@ -496,13 +496,13 @@ public class CensusController { List head0 = new ArrayList<>(); head0.add("上架部门"); List head1 = new ArrayList<>(); - head0.add("类型"); + head1.add("类型"); List head2 = new ArrayList<>(); - head0.add("资源名称"); + head2.add("资源名称"); List head3 = new ArrayList<>(); - head0.add("日期"); + head3.add("日期"); List head4 = new ArrayList<>(); - head0.add("状态"); + head4.add("状态"); list.add(head0); list.add(head1); list.add(head2); @@ -559,15 +559,15 @@ public class CensusController { List head0 = new ArrayList<>(); head0.add("提供部门"); List head1 = new ArrayList<>(); - head0.add("资源名称"); + head1.add("资源名称"); List head2 = new ArrayList<>(); - head0.add("类型"); + head2.add("类型"); List head3 = new ArrayList<>(); - head0.add("申请部门"); + head3.add("申请部门"); List head4 = new ArrayList<>(); - head0.add("日期"); + head4.add("日期"); List head5 = new ArrayList<>(); - head0.add("状态"); + head5.add("状态"); list.add(head0); list.add(head1); list.add(head2); From 094d27fddfedb19342c725fe9301e2b2061c8a23 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 13:43:54 +0800 Subject: [PATCH 17/20] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/renren/common/controller/CensusController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 23e2d022..b4708702 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 @@ -402,7 +402,7 @@ public class CensusController { }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力使用情况", "UTF-8").replaceAll("\\+", "%20"); + String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力使用情况_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); EasyExcel.write(response.getOutputStream(), SelectApplyDeptDetailTypeCountListExcel.class).sheet("使用情况").doWrite(date); } @@ -444,7 +444,7 @@ public class CensusController { }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力上架情况", "UTF-8").replaceAll("\\+", "%20"); + String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力上架情况_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class).sheet("上架情况").doWrite(date); } @@ -486,7 +486,7 @@ public class CensusController { }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("部门上架资源及审批结果详细信息", "UTF-8").replaceAll("\\+", "%20"); + String fileName = URLEncoder.encode("部门上架资源及审批结果详细信息_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead()).sheet("上架情况").doWrite(date); } @@ -549,7 +549,7 @@ public class CensusController { }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("部门申请资源及审批结果详细信息", "UTF-8").replaceAll("\\+", "%20"); + String fileName = URLEncoder.encode("部门申请资源及审批结果详细信息_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); EasyExcel.write(response.getOutputStream()).head(exportSelectCensusApplyTableHead()).sheet("申请情况").doWrite(date); } From f1d3fea4244eb6466cef74eda6249098042a37c6 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 14:38:41 +0800 Subject: [PATCH 18/20] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=A1=A8=E5=A4=B4?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 22 ++++- .../config/CustomCellWriteHeightConfig.java | 58 ++++++++++++ .../config/CustomCellWriteWeightConfig.java | 93 +++++++++++++++++++ 3 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteHeightConfig.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java 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 b4708702..44615e44 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 @@ -11,6 +11,8 @@ import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.resource.dao.ResourceDao; import io.renren.modules.resource.excel.census.SelectApplyDeptDetailTypeCountListExcel; import io.renren.modules.resource.excel.census.SelectDeptDetailTypeCountListExcel; +import io.renren.modules.resource.excel.census.config.CustomCellWriteHeightConfig; +import io.renren.modules.resource.excel.census.config.CustomCellWriteWeightConfig; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.sys.dto.SysDeptDTO; @@ -404,7 +406,10 @@ public class CensusController { response.setCharacterEncoding("utf-8"); String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力使用情况_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), SelectApplyDeptDetailTypeCountListExcel.class).sheet("使用情况").doWrite(date); + EasyExcel.write(response.getOutputStream(), SelectApplyDeptDetailTypeCountListExcel.class) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("使用情况").doWrite(date); } @GetMapping("/selectDeptDetailTypeCountList") @@ -446,7 +451,10 @@ public class CensusController { response.setCharacterEncoding("utf-8"); String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力上架情况_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class).sheet("上架情况").doWrite(date); + EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("上架情况").doWrite(date); } @GetMapping("/selectCensusResourceTable") @@ -488,7 +496,10 @@ public class CensusController { response.setCharacterEncoding("utf-8"); String fileName = URLEncoder.encode("部门上架资源及审批结果详细信息_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead()).sheet("上架情况").doWrite(date); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead()) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("上架情况").doWrite(date); } private List> exportSelectCensusResourceTableHead() { @@ -551,7 +562,10 @@ public class CensusController { response.setCharacterEncoding("utf-8"); String fileName = URLEncoder.encode("部门申请资源及审批结果详细信息_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream()).head(exportSelectCensusApplyTableHead()).sheet("申请情况").doWrite(date); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusApplyTableHead()) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("申请情况").doWrite(date); } private List> exportSelectCensusApplyTableHead() { diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteHeightConfig.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteHeightConfig.java new file mode 100644 index 00000000..e4a15c9c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteHeightConfig.java @@ -0,0 +1,58 @@ +package io.renren.modules.resource.excel.census.config; + + +import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; + +import java.util.Iterator; + + +public class CustomCellWriteHeightConfig extends AbstractRowHeightStyleStrategy { + /** + * 默认高度 + */ + private static final Integer DEFAULT_HEIGHT = 300; + + /** + * Sets the height of header + * + * @param row + * @param relativeRowIndex + */ + @Override + protected void setHeadColumnHeight(Row row, int relativeRowIndex) { + + } + + /** + * Sets the height of content + * + * @param row + * @param relativeRowIndex + */ + @Override + protected void setContentColumnHeight(Row row, int relativeRowIndex) { + Iterator cellIterator = row.cellIterator(); + if (!cellIterator.hasNext()) { + return; + } + + // 默认为 1行高度 + Integer maxHeight = 1; + while (cellIterator.hasNext()) { + Cell cell = cellIterator.next(); + switch (cell.getCellTypeEnum()) { + case STRING: + if (cell.getStringCellValue().indexOf("\n") != -1) { + int length = cell.getStringCellValue().split("\n").length; + maxHeight = Math.max(maxHeight, length); + } + break; + default: + break; + } + } + row.setHeight((short) (maxHeight * DEFAULT_HEIGHT)); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java new file mode 100644 index 00000000..a233c31f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java @@ -0,0 +1,93 @@ +package io.renren.modules.resource.excel.census.config; + +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.metadata.CellData; +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.util.CollectionUtils; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Sheet; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 自适应行宽 + */ +public class CustomCellWriteWeightConfig extends AbstractColumnWidthStyleStrategy { + private Map> CACHE = new HashMap<>(); + + /** + * Sets the column width when head create + * + * @param writeSheetHolder + * @param cellDataList + * @param cell + * @param head + * @param relativeRowIndex + * @param isHead + */ + @Override + protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { + boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList); + if (needSetWidth) { + Map maxColumnWidthMap = CACHE.get(writeSheetHolder.getSheetNo()); + if (maxColumnWidthMap == null) { + maxColumnWidthMap = new HashMap<>(); + CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); + } + + Integer columnWidth = this.dataLength(cellDataList, cell, isHead); + if (columnWidth >= 0) { + if (columnWidth > 254) { + columnWidth = 254; + } + + Integer maxColumnWidth = maxColumnWidthMap.get(cell.getColumnIndex()); + if (maxColumnWidth == null || columnWidth > maxColumnWidth) { + maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth); + Sheet sheet = writeSheetHolder.getSheet(); + sheet.setColumnWidth(cell.getColumnIndex(), columnWidth * 256); + } + + } + } + } + + /** + * 计算长度 + * + * @param cellDataList + * @param cell + * @param isHead + * @return + */ + private Integer dataLength(List cellDataList, Cell cell, Boolean isHead) { + if (isHead) { + return cell.getStringCellValue().getBytes().length; + } else { + CellData cellData = cellDataList.get(0); + CellDataTypeEnum type = cellData.getType(); + if (type == null) { + return -1; + } else { + switch (type) { + case STRING: + // 换行符(数据需要提前解析好) + int index = cellData.getStringValue().indexOf("\n"); + return index != -1 ? + cellData.getStringValue().substring(0, index).getBytes().length + 1 : cellData.getStringValue().getBytes().length + 1; + case BOOLEAN: + return cellData.getBooleanValue().toString().getBytes().length; + case NUMBER: + return cellData.getNumberValue().toString().getBytes().length; + default: + return -1; + } + } + } + } +} From a4047352c125d79083d2dc5dc88e163e8ab376b7 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 15:21:50 +0800 Subject: [PATCH 19/20] npe --- .../common/controller/CensusController.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 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 44615e44..dc0f3f18 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 @@ -485,10 +485,10 @@ public class CensusController { ArrayList resultList = (ArrayList) resourceService.selectCensusResourceTable(params); List> date = resultList.stream().map(index -> { List data = new ArrayList<>(); - data.add(index.getOrDefault("deptName", "").toString()); - data.add(index.getOrDefault("type", "").toString()); - data.add(index.getOrDefault("resourceName", "").toString()); - data.add(index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("deptName", "")); + data.add(index.getOrDefault("type", "")); + data.add(index.getOrDefault("resourceName", "")); + data.add(index.getOrDefault("createDate", "")); data.add(index.getOrDefault("approveStatus", "").toString()); return data; }).collect(Collectors.toList()); @@ -550,12 +550,12 @@ public class CensusController { ArrayList resultList = (ArrayList) resourceService.selectCensusApplyTable(params); List> date = resultList.stream().map(index -> { List data = new ArrayList<>(); - data.add(index.getOrDefault("resourceDeptName", "").toString()); - data.add(index.getOrDefault("resourceName", "").toString()); - data.add(index.getOrDefault("type", "").toString()); - data.add(index.getOrDefault("deptName", "").toString()); - data.add(index.getOrDefault("createDate", "").toString()); - data.add(index.getOrDefault("approveStatus", "").toString()); + data.add(index.getOrDefault("resourceDeptName", "")); + data.add(index.getOrDefault("resourceName", "")); + data.add(index.getOrDefault("type", "")); + data.add(index.getOrDefault("deptName", "")); + data.add(index.getOrDefault("createDate", "")); + data.add(index.getOrDefault("approveStatus", "")); return data; }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); From f2a1b152a8bc97003ed040cd308af134be81ab47 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 15:43:22 +0800 Subject: [PATCH 20/20] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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 dc0f3f18..d8ddc33b 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 @@ -485,11 +485,11 @@ public class CensusController { ArrayList resultList = (ArrayList) resourceService.selectCensusResourceTable(params); List> date = resultList.stream().map(index -> { List data = new ArrayList<>(); - data.add(index.getOrDefault("deptName", "")); - data.add(index.getOrDefault("type", "")); - data.add(index.getOrDefault("resourceName", "")); - data.add(index.getOrDefault("createDate", "")); - data.add(index.getOrDefault("approveStatus", "").toString()); + data.add(index.getOrDefault("deptName", "") == null ? "" : index.getOrDefault("deptName", "").toString()); + data.add(index.getOrDefault("type", "") == null ? "" : index.getOrDefault("type", "").toString()); + data.add(index.getOrDefault("resourceName", "") == null ? "" : index.getOrDefault("resourceName", "").toString()); + data.add(index.getOrDefault("createDate", "") == null ? "" : index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("approveStatus", "") == null ? "" : index.getOrDefault("approveStatus", "").toString()); return data; }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); @@ -550,12 +550,12 @@ public class CensusController { ArrayList resultList = (ArrayList) resourceService.selectCensusApplyTable(params); List> date = resultList.stream().map(index -> { List data = new ArrayList<>(); - data.add(index.getOrDefault("resourceDeptName", "")); - data.add(index.getOrDefault("resourceName", "")); - data.add(index.getOrDefault("type", "")); - data.add(index.getOrDefault("deptName", "")); - data.add(index.getOrDefault("createDate", "")); - data.add(index.getOrDefault("approveStatus", "")); + data.add(index.getOrDefault("resourceDeptName", "") == null ? "" : index.getOrDefault("resourceDeptName", "").toString()); + data.add(index.getOrDefault("resourceName", "") == null ? "" : index.getOrDefault("resourceName", "").toString()); + data.add(index.getOrDefault("type", "") == null ? "" : index.getOrDefault("type", "").toString()); + data.add(index.getOrDefault("deptName", "") == null ? "" : index.getOrDefault("deptName", "").toString()); + data.add(index.getOrDefault("createDate", "") == null ? "" : index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("approveStatus", "") == null ? "" : index.getOrDefault("approveStatus", "").toString()); return data; }).collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");