From 9a6358bd5d944717dc08c1a87ec4c11a32200d2a Mon Sep 17 00:00:00 2001 From: yitonglei Date: Sat, 25 Jun 2022 14:50:43 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=BB=A7=E7=BB=AD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=B0=E8=83=BD=E5=8A=9B=E7=BB=9F=E8=AE=A1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=90=8E=E5=8F=B0=E4=BB=A3=E7=A0=81--?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E8=B4=A1=E7=8C=AE=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=A2=AB=E5=A4=9A=E5=B0=91=E5=BA=94=E7=94=A8=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV3.java | 118 +++++++++++++++--- .../modules/resource/dao/ResourceDao.java | 1 + .../service/impl/ResourceServiceImpl.java | 1 + .../sys/controller/SysDeptController.java | 7 ++ .../resources/mapper/resource/ResourceDao.xml | 5 + 5 files changed, 114 insertions(+), 18 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 96d8408f..d9f95d97 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 @@ -4,22 +4,24 @@ 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.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.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.util.CollectionUtils; 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.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CopyOnWriteArrayList; @@ -36,6 +38,8 @@ public class CensusControllerV3 { private ResourceService resourceService; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SysDeptService sysDeptService; /** @@ -188,12 +192,6 @@ public class CensusControllerV3 { return null; } - @GetMapping("/assemblerUsedDistriInfo") - @ApiOperation("应用领域分布情况") - @LogOperation("应用领域分布情况") - public Result>> assemblerUsedDistriInfo(Long id){ - return null; - } //以下是组件使用情况点击详情 @@ -218,12 +216,6 @@ public class CensusControllerV3 { } - @GetMapping("/assemblerUseDistriInfo") - @ApiOperation("用组件应用领域分布情况") - @LogOperation("用组件应用领域分布情况") - public Result>> assemblerUseDistriInfo(Long id){ - return null; - } @GetMapping("/assemblerUseScoreTopInfo") @ApiOperation("使用组件评分top5") @@ -248,18 +240,30 @@ public class CensusControllerV3 { return new Result>>().ok(result); } - @GetMapping("applicationAreaCapabilitySet") + @GetMapping("applicationAreaCapabilityList") @ApiOperation("应用领域分布情况") @LogOperation("应用领域分布情况") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"), @ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String") }) - public Result>> applicationAreaCapabilitySet(@ApiIgnore @RequestParam Map params) { + public Result>> applicationAreaCapabilityList(@ApiIgnore @RequestParam Map params) { return new Result>>().ok(resourceService.applicationAreaCapabilityList(params)); } + @GetMapping("applicationUsedAreaCapabilityList") + @ApiOperation("使用组件的应用领域分布情况") + @LogOperation("使用组件的应用领域分布情况") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"), + @ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String") + }) + public Result>> applicationUsedAreaCapabilityList(@ApiIgnore @RequestParam Map params) { + return null; + } + + //以下是应用资源点击详情显示 @GetMapping("/applicationStateCapabilitySet") @@ -295,6 +299,28 @@ public class CensusControllerV3 { return new Result>>().ok(result); } + @GetMapping("/applicationUsedCapabilityNum") + @ApiOperation("贡献组件被多少应用使用") + @LogOperation("贡献组件被多少应用使用") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"), + @ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String") + }) + public Result>> applicationUsedCapabilityNum(@ApiIgnore @RequestParam Map params){ + List> result = new ArrayList<>(); + Object[] ps = {params.get("resourceType"),params.get("id")}; + result = jdbcTemplate.queryForList("SELECT a.name,b.attr_value FROM tb_data_resource a INNER JOIN tb_data_attr b \n" + + "ON a.id = b.data_resource_id\n" + + "WHERE a.type = ? and a.dept_id = ?\n" + + "and b.attr_type = '应用领域'",ps); + result.forEach(r->{ + String[] strArr = r.get("attr_value").toString().split(","); + r.put("usedNum",strArr.length); + }); + + return new Result>>().ok(result); + } + //以下是基础设施和数据资源使用情况点击详情(申请明细) @GetMapping("/assemblerCarDetail") @ApiOperation("基础设施或数据资源使用情况之申请明细") @@ -332,4 +358,60 @@ public class CensusControllerV3 { return new Result>>().ok(result); } + + /** + * 测试获取部门树 + * @param keywords + * @param deptId + * @return + */ + @GetMapping("treeList") + @ApiOperation("根据当前用户所在部门查询下属部门tree,可以根据部门名称模糊查询") + public Result> treeList(@RequestParam(required = false,value = "模糊查询,部门名称") String keywords,Long deptId){ + List result = new ArrayList<>(); + SysDeptDTO sysDeptDTO = sysDeptService.get(deptId); + + //市大数据局展示全部部门,区大数据局展示本区所有部门,委办局展示自己部门及下级部门 + if(StringUtils.contains(sysDeptDTO.getName(),"青岛市大数据发展管理局")){//市大数据局 + List> deptMaps = jdbcTemplate.queryForList("SELECT id FROM sys_dept where pid = 0"); + deptMaps.forEach(dept->{ + List depts = sysDeptService.getDeptListByPid(Long.valueOf(dept.get("id").toString())); + result.addAll(depts); + }); + }else if(StringUtils.contains(sysDeptDTO.getName(),"大数据") && sysDeptDTO.getType() == 3){//各区大数据局 + + List depts = sysDeptService.getDeptListByPid(sysDeptDTO.getPid()); + result.addAll(depts); + }else{ + List deptListByPid = sysDeptService.getDeptListByPid(deptId); + result.addAll(deptListByPid); + } + if(keywords != null){ + treeMatch(result,keywords); + } + System.out.println("部门树--》"+result.size()); + return new Result>().ok(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(); + } + } + } + } + } 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 7ce8c305..dc13f9bb 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 @@ -120,4 +120,5 @@ public interface ResourceDao extends BaseDao { // List> selectDeptList(Map params); List> selectResurceCarDetails(Map params); List> applicationAreaCapabilityList(Map params); + List> applicationUsedAreaCapabilityList(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 ade0819e..e9dd3bf4 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 @@ -737,6 +737,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> applicationAreaCapabilityList(Map params){ return resourceDao.applicationAreaCapabilityList(params); } + @Override public Object selectResourceListByType(String type) { return resourceDao.selectByType(type); 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 e3bb2d88..1a1a1efb 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 @@ -1,6 +1,7 @@ package io.renren.modules.sys.controller; import io.renren.common.annotation.LogOperation; +import io.renren.common.dao.BaseDao; import io.renren.common.utils.Result; import io.renren.common.validator.AssertUtils; import io.renren.common.validator.ValidatorUtils; @@ -12,14 +13,18 @@ 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.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; /** * 部门管理 @@ -31,6 +36,8 @@ import java.util.List; public class SysDeptController { @Autowired private SysDeptService sysDeptService; + @Autowired + private JdbcTemplate jdbcTemplate; /** ytl 2022-06-23 新增 start **/ @GetMapping("treeList") diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 87d1ea3a..2151c6ff 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -930,6 +930,9 @@ GROUP BY type + + + \ No newline at end of file