From d06b2c9ec3d6fe3102dd7eca6d5cf6a51179ade8 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Fri, 24 Jun 2022 16:37:14 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E8=83=BD=E5=8A=9B=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=A1=B5=E9=9D=A2=E9=83=A8=E5=88=86=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV3.java | 242 +++++++++++++++ .../modules/resource/dao/ResourceDao.java | 10 + .../resource/service/ResourceService.java | 10 + .../service/impl/ResourceServiceImpl.java | 290 ++++++++++++++++++ .../modules/security/config/ShiroConfig.java | 2 +- .../sys/controller/SysDeptController.java | 36 ++- .../io/renren/modules/sys/dao/SysDeptDao.java | 2 + .../modules/sys/service/SysDeptService.java | 2 + .../sys/service/impl/SysDeptServiceImpl.java | 28 ++ .../resources/mapper/resource/ResourceDao.xml | 141 +++++++++ .../main/resources/mapper/sys/SysDeptDao.xml | 3 + 11 files changed, 764 insertions(+), 2 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java 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 new file mode 100644 index 00000000..26c8517f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java @@ -0,0 +1,242 @@ +package io.renren.common.controller; + +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.utils.Result; +import io.renren.modules.resource.service.ResourceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * 全局统计中心 V3,对应2022-06-23能力统计列表和详情切图 + * @author ytl + * @Date 2022/6/23 14:04 + **/ +@Api(tags = "全局统计中心v3") +@RestController +@RequestMapping("/census/center/v3") +public class CensusControllerV3 { + @Autowired + private ResourceService resourceService; + @Autowired + private JdbcTemplate jdbcTemplate; + + + /** + * 五大资源之发布情况统计 + * 组件服务 应用资源 基础设施 数据资源 知识库 + * @param + * @return + */ + @GetMapping("/resourceReleaseDetails") + @ApiOperation("五大资源之发布情况统计") + @LogOperation("五大资源之发布情况统计") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = "id",value = "行政部门编号", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String"), + //@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String") + }) + public Result>> resourceAssemblerDetails(@ApiIgnore @RequestParam Map params){ + String type = params.get("resourceType").toString(); + List> list = new ArrayList<>(); + switch (type){ + case "组件服务": + list = resourceService.resourceBusinessDetails(params); + break; + case "应用资源": + list = resourceService.resourceApplicationDetails(params); + break; + case "基础设施": + list = resourceService.resourceInfrastructureDetails(params); + break; + case "数据资源": + list = resourceService.resourceDatasDetails(params); + break; + case "知识库": + list = resourceService.resourceKnowledgeDetails(params); + } + return new Result>>().ok(list); + } + + @GetMapping("/resourceUsedDetails") + @ApiOperation("五大资源之使用情况统计") + @LogOperation("五大资源之使用情况统计") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = "id",value = "行政部门编号", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String"), + //@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String") + }) + public Result>> resourceUsedDetails(@ApiIgnore @RequestParam Map params){ + String type = params.get("resourceType").toString(); + List> list = new ArrayList<>(); + + switch (type){ + case "组件服务": + list = resourceService.resourceBusinessUseDetails(params); + break; + case "应用资源": + break; + case "基础设施": + list = resourceService.resourceDatasUseDetails(params); + break; + case "数据资源": + list = resourceService.resourceDatasUseDetails(params); + break; + case "知识库": + break; + } + return new Result>>().ok(list); + } + + + //以下是组件服务发布情况点击详情 + + /** + * 组件评分情况 1 2 3 4 5评分分布 + * @param id 部门id + * @return + */ + @GetMapping("/assemblerScoreInfo") + @ApiOperation("组件评分情况") + @LogOperation("组件评分情况") + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long") + public Result>> assemblerScoreInfo(Long id){ + Object[] args = {id}; + List> maps = jdbcTemplate.queryForList("SELECT COUNT(a.score) as scoreNum,a.score FROM \n" + + "tb_resource_score a\n" + + "INNER JOIN \n" + + "tb_data_resource b\n" + + "ON \n" + + "a.resource_id = b.id\n" + + "WHERE \n" + + "b.type = '组件服务'\n" + + "AND\n" + + "b.dept_id = ?\n" + + "AND\n" + + "a.score is not null\n" + + "AND a.del_flag = 0\n" + + "GROUP BY a.score", args); + + return new Result>>().ok(maps); + } + + @GetMapping("/assemblerUsedTopInfo") + @ApiOperation("TOP5被调用的组件和数量") + @LogOperation("TOP5被调用的组件和数量") + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long") + public Result>> assemblerUsedTopInfo(Long id){ + return null; + } + + @GetMapping("/assemblerCollectionTopInfo") + @ApiOperation("TOP5被收藏的组件和数量") + @LogOperation("TOP5被收藏的组件和数量") + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long") + public Result>> assemblerCollectionTopInfo(Long id){ + Object[] args = {id}; + + List> maps = jdbcTemplate.queryForList("SELECT a.resource_id,b.name,COUNT(a.id) AS collectionNum\n" + + "FROM tb_resource_collection a \n" + + "INNER JOIN tb_data_resource b \n" + + "ON a.resource_id = b.id\n" + + "WHERE\n" + + "b.dept_id = ?\n" + + "AND\n" + + "b.type = '组件服务'\n" + + "AND \n" + + "a.del_flag = 0\n" + + "\n" + + "GROUP BY a.resource_id,b.name \n" + + "ORDER BY COUNT(a.id) DESC\n" + + "LIMIT 5", args); + + return new Result>>().ok(maps); + } + + + @GetMapping("/assemblerUsedInfo") + @ApiOperation("算法、图层、开发、业务发布量情况分布") + @LogOperation("算法、图层、开发、业务发布量情况分布") + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long") + public Result>> assemblerUsedInfo(Long id){ + return null; + } + + @GetMapping("/assemblerUsedDistriInfo") + @ApiOperation("应用领域分布情况") + @LogOperation("应用领域分布情况") + public Result>> assemblerUsedDistriInfo(Long id){ + return null; + } + + //以下是组件使用情况点击详情 + + @GetMapping("/assemblerUseTopInfo") + @ApiOperation("TOP5使用组件") + @LogOperation("TOP5使用组件") + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long") + public Result>> assemblerUseTopInfo(Long id){ + return null; + } + + @GetMapping("/assemblerUseInfo") + @ApiOperation("使用组件数量分布(算法、图层、开发、业务") + @LogOperation("使用组件数量分布(算法、图层、开发、业务") + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long") + public Result>> assemblerUseInfo(Long id){ + return null; + } + + + @GetMapping("/assemblerUseDistriInfo") + @ApiOperation("用组件应用领域分布情况") + @LogOperation("用组件应用领域分布情况") + public Result>> assemblerUseDistriInfo(Long id){ + return null; + } + + @GetMapping("/assemblerUseScoreTopInfo") + @ApiOperation("使用组件评分top5") + @LogOperation("使用组件评分top5") + public Result>> assemblerUseScoreTopInfo(Long id){ + return null; + } + + //以下是应用资源点击详情显示 + + //以下是基础设施和数据资源使用情况点击详情(申请明细) + @GetMapping("/assemblerCarDetail") + @ApiOperation("基础设施或数据资源使用情况之申请明细") + @LogOperation("基础设施或数据资源使用情况之申请明细") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = "id",value = "行政部门编号", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String"), + }) + public Result>> assemblerCarDetail(@ApiIgnore @RequestParam Map params){ + List> result = resourceService.assemblerCarDetail(params); + + return new Result>>().ok(result); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java index 5df5e743..b56d9be5 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java @@ -109,4 +109,14 @@ public interface ResourceDao extends BaseDao { List selectTopFiveComponentServiceApplications(); List selectTopFiveComponentServiceScore(); + + List selectResourceNumAsType(Map params); + + Integer selectResourceCarNum(Map params); + Integer selectResourceCollectionNum(Map params); + Integer selectResourceBrowseNum(Map params); + Integer selectResourceRelNum(Map params); + Integer selectResourceShare(Map params); + // List> selectDeptList(Map params); + List> selectResurceCarDetails(Map params); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index 979c40d5..7f3f0716 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -83,4 +83,14 @@ public interface ResourceService extends CrudService> resourceBusinessDetails(Map map); + List> resourceBusinessUseDetails(Map map); + List> resourceDatasUseDetails(Map map); + //List> selectDeptList(Map params); + List> resourceApplicationDetails(Map params); + List> resourceInfrastructureDetails(Map params); + List> resourceDatasDetails(Map params); + List> resourceKnowledgeDetails(Map params); + List> assemblerCarDetail(Map params); } \ No newline at end of file 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 16689f53..8b36c1da 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 @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.collect.Lists; import io.renren.common.constant.Constant; import io.renren.common.domain.Tsingtao_xhaProperties; import io.renren.common.service.impl.CrudServiceImpl; @@ -46,6 +47,7 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -866,4 +868,292 @@ public class ResourceServiceImpl extends CrudServiceImpl> resourceBusinessDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + + List deptList = new ArrayList<>();//保存部门 发布总数 访问量 + params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString())); + params.put("pageSize", params.get("limit")); + + + Integer page = Integer.parseInt(params.get("page").toString()) - 1; + Integer pageSize = Integer.parseInt(params.get("limit").toString()); + + Object[] pas = {params.get("id"),params.get("id"),page,pageSize}; + + List> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName,\n" + + "SUM(a.visits) AS resourceVisits \n" + + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + + "WHERE a.type = '组件服务' AND a.del_flag = 0\n" + + "AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" + + "GROUP BY a.dept_id,b.name\n" + + "ORDER BY a.dept_id,b.name\n" + + "LIMIT ?,?",pas); + + result.addAll(result2); + + ConcurrentHashMap hashMap = new ConcurrentHashMap(); + hashMap.putAll(params); + + CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> { // 获取被申请数量 + result.forEach(dept -> { + String id = dept.get("deptId").toString();//部门id + hashMap.put("id", id); + Integer resourceCarNum = baseDao.selectResourceCarNum(hashMap); + dept.put("resourceCarNum", resourceCarNum); + }); + }); + + CompletableFuture voidCompletableFuture02 = CompletableFuture.runAsync(() -> { // 获取被被收藏数量 + result.forEach(dept -> { + String id = dept.get("deptId").toString();//部门id + hashMap.put("id", id); + Integer resourceCollectionNum = baseDao.selectResourceCollectionNum(hashMap); + dept.put("resourceCollectionNum", resourceCollectionNum); + }); + }); + + CompletableFuture voidCompletableFuture03 = CompletableFuture.runAsync(() -> { // 获取被被浏览数量 + result.forEach(dept -> { + String id = dept.get("deptId").toString();//部门id + hashMap.put("id", id); + Integer resourceBrowseNum = baseDao.selectResourceBrowseNum(hashMap); + dept.put("resourceBrowseNum", resourceBrowseNum); + }); + }); + + CompletableFuture voidCompletableFuture04 = CompletableFuture.runAsync(() -> { // 获取被被应用数量 + result.forEach(dept -> { + String id = dept.get("deptId").toString();//部门id + hashMap.put("id", id); + Integer resourceRelNum = baseDao.selectResourceRelNum(hashMap); + dept.put("resourceRelNum", resourceRelNum); + }); + }); + + CompletableFuture voidCompletableFuture05 = CompletableFuture.runAsync(() -> { // 获取需申请数量 免批数量 + result.forEach(dept -> { + String id = dept.get("deptId").toString();//部门id + hashMap.put("id", id); + hashMap.put("shareCondition", "申请"); + Integer resourceShareNum = baseDao.selectResourceShare(hashMap); + dept.put("resourceShareNum", resourceShareNum); + hashMap.put("shareCondition", "免批申请"); + Integer resourceShareNonNum = baseDao.selectResourceShare(hashMap); + dept.put("resourceShareNonNum", resourceShareNonNum); + }); + }); + + //还缺少被调用总数 + CompletableFuture all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02, voidCompletableFuture03,voidCompletableFuture04,voidCompletableFuture05); + all.join(); + + return result; + } + + @Override + public List> resourceApplicationDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + Integer page = Integer.parseInt(params.get("page").toString()) - 1; + Integer pageSize = Integer.parseInt(params.get("limit").toString()); + + Object[] pas = {params.get("id"),params.get("id"),page,pageSize}; + + List> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + + "WHERE a.type = '应用资源' AND a.del_flag = 0\n" + + "AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" + + "GROUP BY a.dept_id,b.name\n" + + "ORDER BY a.dept_id,b.name\n" + + "LIMIT ?,?",pas); + result.addAll(result2); + CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> { //应用浏览数量 + result.forEach(r -> { + Object[] qu = {r.get("deptId")}; + Integer integer = baseDao.selectResourceBrowseNum(params); + r.put("resourceBrowseNum", integer); + }); + }); + + CompletableFuture voidCompletableFuture02 = CompletableFuture.runAsync(() -> { //应用收藏量 + result.forEach(r -> { + Object[] qu = {r.get("deptId")}; + Integer integer = baseDao.selectResourceCarNum(params); + r.put("resourceCarNum", integer); + }); + }); + + CompletableFuture all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02); + all.join(); + + return result; + } + + @Override + public List> resourceInfrastructureDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + Integer page = Integer.parseInt(params.get("page").toString()) - 1; + Integer pageSize = Integer.parseInt(params.get("limit").toString()); + + Object[] pas = {params.get("id"),params.get("id"),page,pageSize}; + + List> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + + "WHERE a.type = '基础设施' AND a.del_flag = 0\n" + + "AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" + + "GROUP BY a.dept_id,b.name\n" + + "ORDER BY a.dept_id,b.name\n" + + "LIMIT ?,?",pas); + result.addAll(result2); + + CompletableFuture resourceCollectionNum01 = CompletableFuture.runAsync(() -> {//被申请数量 resourceCarNum + result.forEach(r -> { + Integer integer = baseDao.selectResourceCarNum(params); + r.put("resourceCarNum", integer); + }); + }); + + CompletableFuture resourceCollectionNum02 = CompletableFuture.runAsync(() -> {//被浏览数量 + result.forEach(r -> { + Integer integer = baseDao.selectResourceBrowseNum(params); + r.put("resourceBrowseNum", integer); + }); + }); + + CompletableFuture resourceCollectionNum03 = CompletableFuture.runAsync(() -> {//被收藏数量 + result.forEach(r -> { + Integer integer = baseDao.selectResourceCollectionNum(params); + r.put("resourceCollectionNum", integer); + }); + }); + + CompletableFuture all = CompletableFuture.allOf(resourceCollectionNum01, resourceCollectionNum02, resourceCollectionNum03); + all.join(); + + return result; + } + + @Override + public List> resourceDatasDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + Integer page = Integer.parseInt(params.get("page").toString()) - 1; + Integer pageSize = Integer.parseInt(params.get("limit").toString()); + + Object[] pas = {params.get("id"),params.get("id"),page,pageSize}; + + List> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + + "WHERE a.type = '数据资源' AND a.del_flag = 0\n" + + "AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" + + "GROUP BY a.dept_id,b.name\n" + + "ORDER BY a.dept_id,b.name\n" + + "LIMIT ?,?",pas); + result.addAll(result2); + + CompletableFuture resourceCarNum = CompletableFuture.runAsync(() -> { //被申请数量 + result.forEach(re -> { + Integer integer = baseDao.selectResourceCarNum(params); + re.put("resourceCarNum", integer); + }); + }); + + CompletableFuture resourceBrowseNum = CompletableFuture.runAsync(() -> { //被浏览数量 + result.forEach(re -> { + Integer integer = baseDao.selectResourceBrowseNum(params); + re.put("resourceBrowseNum", integer); + }); + }); + + CompletableFuture resourceCollectionNum = CompletableFuture.runAsync(() -> { //被收藏数量 + result.forEach(re -> { + Integer integer = baseDao.selectResourceCollectionNum(params); + re.put("resourceCollectionNum", integer); + }); + }); + + CompletableFuture all = CompletableFuture.allOf(resourceCarNum, resourceBrowseNum, resourceCollectionNum); + all.join(); + + return result; + } + + @Override + public List> resourceKnowledgeDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + Integer page = Integer.parseInt(params.get("page").toString()) - 1; + Integer pageSize = Integer.parseInt(params.get("limit").toString()); + + Object[] pas = {params.get("id"),params.get("id"),page,pageSize}; + + List> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + + "WHERE a.type = '知识库' AND a.del_flag = 0\n" + + "AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" + + "GROUP BY a.dept_id,b.name\n" + + "ORDER BY a.dept_id,b.name\n" + + "LIMIT ?,?",pas); + result.addAll(result2); + + return result; + } + +// @Override +// public List> selectDeptList(Map params){ +// List> list = new ArrayList<>(); +// Map map = new HashMap(); +// map.put("id",params.get("id")); +// Object[] id ={params.get("id")}; +// //List> ids = baseDao.selectDeptList(map); +// List> maps = jdbcTemplate.queryForList(" SELECT id\n" + +// " FROM\n" + +// " sys_dept\n" + +// " WHERE\n" + +// " pid = ?", id); +// if(maps.size() > 0){ +// for(int i =0;i> resourceBusinessUseDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString())); + params.put("pageSize", params.get("limit")); + result = baseDao.selectResurceCarDetails(params); + + //还缺少调用总数 + //CompletableFuture all = CompletableFuture.allOf(resourceCarNums); + //all.join(); + return result; + } + + @Override + public List> resourceDatasUseDetails(Map params){ + List> result = new CopyOnWriteArrayList<>(); + params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString())); + params.put("pageSize", params.get("limit")); + result = baseDao.selectResurceCarDetails(params); + return result; + } + + @Override + public List> assemblerCarDetail(Map params){ + List> result = new ArrayList<>(); + Object[] ps = {params.get("id"),params.get("resourceType"),(Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()),Integer.parseInt(params.get("limit").toString())}; + result = jdbcTemplate.queryForList("\n" + + "SELECT a.*,b.username,c.name as resourcename from tb_resource_car a inner join sys_user b on a.user_id = b.id \n" + + "inner join tb_data_resource c on a.resource_id = c.id \n" + + "where b.dept_id = ? and c.type = ?\n" + + "order by a.create_date desc \n" + + "limit ?,?\n",ps); + + return result; + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java index 923c2a3b..aa558749 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java +++ b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java @@ -75,7 +75,7 @@ public class ShiroConfig { filterMap.put("/front/**", "anon"); filterMap.put("/applyRecord/**", "anon"); filterMap.put("/bsabilityrecord/**", "anon"); - + filterMap.put("/census/center/v3/**", "anon"); /** * 资源上传 */ diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java index dd747c10..e3bb2d88 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java @@ -7,15 +7,18 @@ import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.security.user.SecurityUser; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.service.SysDeptService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import java.util.HashMap; +import java.util.Iterator; import java.util.List; /** @@ -29,6 +32,17 @@ public class SysDeptController { @Autowired private SysDeptService sysDeptService; + /** ytl 2022-06-23 新增 start **/ + @GetMapping("treeList") + @ApiOperation("根据当前用户所在部门查询下属部门tree,可以根据部门名称模糊查询") + public Result> treeList(@RequestParam(required = false,value = "模糊查询,部门名称") String keywords){ + Long deptId = SecurityUser.getDeptId(); + List deptListByPid = sysDeptService.getDeptListByPid(deptId); + treeMatch(deptListByPid,keywords); + + return new Result>().ok(deptListByPid); + } + /** ytl 2022-06-23 新增 end **/ @GetMapping("list") @ApiOperation("列表") // @RequiresPermissions("sys:dept:list") @@ -85,5 +99,25 @@ public class SysDeptController { return new Result(); } - + + private void treeMatch(List anyLevelCategoryList, String keyword) { + Iterator iter = anyLevelCategoryList.iterator(); + while (iter.hasNext()) { + // 获取当前遍历到的目录 + SysDeptDTO category = iter.next(); + // 如果当前目录名称包含关键字,则什么也不做(不移除),否则就看下一级 + if (!category.getName().contains(keyword)) { + // 取出下一级目录集合 + List childrenCategoryList = category.getChildren(); + // 递归 + if (!CollectionUtils.isEmpty(childrenCategoryList)) { + treeMatch(childrenCategoryList, keyword); + } + // 下一级目录看完了,如果下一级目录全部被移除,则移除当前目录 + if (CollectionUtils.isEmpty(category.getChildren())) { + iter.remove(); + } + } + } + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java index 98a8816c..8f41cffb 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java @@ -1,6 +1,7 @@ package io.renren.modules.sys.dao; import io.renren.common.dao.BaseDao; +import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.entity.SysDeptEntity; import org.apache.ibatis.annotations.Mapper; @@ -36,4 +37,5 @@ public interface SysDeptDao extends BaseDao { */ SysDeptEntity getByName(String name); + List getDeptListByPid(SysDeptEntity sysDeptEntity); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/SysDeptService.java b/renren-admin/src/main/java/io/renren/modules/sys/service/SysDeptService.java index 12dd7d85..a9328a0a 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/SysDeptService.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/SysDeptService.java @@ -30,4 +30,6 @@ public interface SysDeptService extends BaseService { List getSubDeptIdList(Long id); SysDeptDTO getByName(String name); + + List getDeptListByPid(Long id); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDeptServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDeptServiceImpl.java index 395ff8b1..8fa8e429 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDeptServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDeptServiceImpl.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.*; @@ -120,6 +121,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl getDeptListByPid(Long id) { + SysDeptEntity sysDeptEntity = baseDao.getById(id);//当前部门 + SysDeptDTO sysDeptDTO = ConvertUtils.sourceToTarget(sysDeptEntity, SysDeptDTO.class);//转换为DTO + + List sysDeptList = baseDao.getDeptListByPid(sysDeptEntity);//下级部门 + List sysDeptDTOList = new ArrayList<>(); + + if(sysDeptList.size() > 0){ + sysDeptList.forEach(dept->sysDeptDTOList.add(ConvertUtils.sourceToTarget(dept, SysDeptDTO.class))); + for(int i = 0; i list = getDeptListByPid(sysDeptList.get(i).getId()); + sysDeptDTOList.get(i).setChildren(list); + } + sysDeptDTO.setChildren(sysDeptDTOList); + sysDeptDTOList.add(sysDeptDTO); + }else{ + sysDeptDTOList.add(sysDeptDTO); + } + + return sysDeptDTOList; + } + + + } diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 2118dc8d..060297eb 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -938,4 +938,145 @@ LIMIT 5 + + + + + + + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml b/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml index 3d994d64..a93fc6fb 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml @@ -34,4 +34,7 @@ where t1.name = #{name} LIMIT 1 + \ No newline at end of file