From f3670092156fbd51363742e420db49dcc0bf5b8b Mon Sep 17 00:00:00 2001 From: yitonglei Date: Fri, 1 Jul 2022 18:20:54 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E8=83=BD=E5=8A=9B?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=88=97=E8=A1=A8=E5=92=8C=E8=AF=A6=E6=83=85?= =?UTF-8?q?-=E7=BB=84=E4=BB=B6=E6=9C=8D=E5=8A=A1-=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=83=85=E5=86=B5=E7=BB=9F=E8=AE=A1=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=BB=9F=E8=AE=A1=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=95=B0=E5=92=8C=E4=BD=BF=E7=94=A8=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV3.java | 29 +++++++++++---- .../service/impl/ResourceServiceImpl.java | 37 +++++++++++-------- .../resources/mapper/resource/ResourceDao.xml | 15 ++++++-- 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java index e552f0e0..d4cd6186 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java @@ -255,9 +255,17 @@ public class CensusControllerV3 { }) public Result>> assemblerUseInfo(@ApiIgnore @RequestParam Map params){ Object[] ps = {params.get("id"),params.get("id"),params.get("resourceType")}; - List> maps = jdbcTemplate.queryForList("SELECT count(d.id) as num,d.attr_value FROM tb_data_resource_rel a INNER JOIN sys_user b ON a.creator = b.id INNER JOIN tb_data_resource c ON a.reference_id = c.id INNER JOIN tb_data_attr d ON c.id = d.data_resource_id INNER JOIN sys_dept e ON b.dept_id = e.id\n" + - " WHERE a.del_flag = 0 AND (e.id = ? OR INSTR(e.pids,?)) AND c.type = ? AND d.attr_type = '组件类型' \n" + - "GROUP BY d.attr_value", ps); + List> maps = jdbcTemplate.queryForList("SELECT COUNT(n.id) AS num,n.attr_value FROM\n" + + "(\n" + + "\tSELECT DISTINCT(c.id) AS id,c.name FROM \n" + + "\t(\n" + + "\t\tSELECT a.id FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id \n" + + "\t\tWHERE a.del_flag = 0 AND a.type='应用资源' AND (b.id = ? OR INSTR(b.pids,?))\n" + + "\t) a \n" + + "\tINNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id\n" + + "\tWHERE b.del_flag = 0 AND c.type = ? AND c.del_flag = 0 \n" + + "\t \n" + + ") m INNER JOIN tb_data_attr n ON m.id = n.data_resource_id WHERE n.del_flag = 0 AND n.attr_type = '组件类型' GROUP BY n.attr_value", ps); return new Result>>().ok(maps); } @@ -303,10 +311,17 @@ public class CensusControllerV3 { }) public Result>> assemblerUseScoreTopInfo(@ApiIgnore @RequestParam Map params){ Object[] ps = {params.get("resourceType"),params.get("id"),params.get("id")}; - List> maps = jdbcTemplate.queryForList("SELECT SUM(IFNULL(e.score,0)) as score,c.name FROM tb_data_resource_rel a INNER JOIN sys_user b ON a.creator = b.id INNER JOIN tb_data_resource c ON a.reference_id = c.id\n" + - "INNER JOIN sys_dept d ON b.dept_id = d.id INNER JOIN tb_resource_score e ON a.reference_id = e.resource_id \n" + - "WHERE a.del_flag = 0 AND c.type = ? AND c.del_flag = 0 AND (d.id = ? OR INSTR(d.pids,?)) AND e.del_flag = 0\n" + - "group by c.name order by score desc limit 5", ps); + List> maps = jdbcTemplate.queryForList("SELECT SUM(IFNULL(b.score,0)) as score,a.name FROM \n" + + "(\n" + + "\tSELECT DISTINCT(c.id) AS id,c.name FROM \n" + + "\t\t(\n" + + "\t\t\tSELECT a.id FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id \n" + + "\t\t\tWHERE a.del_flag = 0 AND a.type='应用资源' AND (b.id = ? OR INSTR(b.pids,?))\n" + + "\t\t) a \n" + + "\t\tINNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id\n" + + "\t\tWHERE b.del_flag = 0 AND c.type = ? AND c.del_flag = 0 \n" + + ")\ta \n" + + "INNER JOIN tb_resource_score b ON a.id = b.resource_id AND b.del_flag = 0 GROUP BY a.name ORDER BY score DESC LIMIT 5", ps); return new Result>>().ok(maps); } 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 7bef8b8e..824f2418 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 @@ -1408,21 +1408,22 @@ public class ResourceServiceImpl extends CrudServiceImpl(list, list.size()); } - //分别根据部门获取组件使用总数和申请组件数 - Map paraMap = new ConcurrentHashMap<>(); - paraMap.put("resourceType", params.get("resourceType")); - CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> { - maps.forEach(m -> { - paraMap.put("id", m.get("deptId")); - Map maps1 = new HashMap<>(); - maps1 = baseDao.assemblyCarByDept(paraMap); - if (maps1 == null) { - m.put("resourceCarNum", 0); - } else { - m.put("resourceCarNum", maps1.get("carNum") == null ? 0 : maps1.get("carNum")); - } - }); - }); + Map paraMap = new ConcurrentHashMap<>(); + paraMap.put("resourceType", params.get("resourceType")); + //分别根据部门获取组件使用总数和调用数 + //申请数 +// CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> { +// maps.forEach(m -> { +// paraMap.put("id", m.get("deptId")); +// Map maps1 = new HashMap<>(); +// maps1 = baseDao.assemblyCarByDept(paraMap); +// if (maps1 == null) { +// m.put("resourceCarNum", 0); +// } else { +// m.put("resourceCarNum", maps1.get("carNum") == null ? 0 : maps1.get("carNum")); +// } +// }); +// }); //本部门的应用关联的组件数量 CompletableFuture voidCompletableFuture02 = CompletableFuture.runAsync(() -> { @@ -1437,6 +1438,12 @@ public class ResourceServiceImpl extends CrudServiceImpl voidCompletableFuture01 = CompletableFuture.runAsync(() -> { + maps.forEach(m -> { + m.put("resourceCallNum",0); + }); + }); CompletableFuture all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02); all.join(); diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index e516a300..d9b53aea 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1080,10 +1080,17 @@ SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS type , COUNT( tdav.data_resource_id ) AS total FROM - ( select a.* from tb_data_attr a inner join tb_data_resource d on a.data_resource_id = d.id - inner join tb_data_resource_rel e on e.reference_id = d.id inner join sys_user f on e.creator = f.id - inner join sys_dept g on f.dept_id = g.id - where d.type=#{resourceType} and (g.id = #{id} OR instr(g.pids,#{id})) + ( + SELECT b.* FROM + ( + SELECT DISTINCT(c.id) AS id FROM + ( + SELECT a.id FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id + WHERE a.del_flag = 0 AND a.type='应用资源' AND (b.id = #{id} OR INSTR(b.pids,#{id})) + ) a + INNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id + WHERE b.del_flag = 0 AND c.type = #{resourceType} AND c.del_flag = 0 + ) a INNER JOIN tb_data_attr b ON a.id = b.data_resource_id AND b.del_flag = 0 ) tdav JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )