Compare commits

..

4 Commits

Author SHA1 Message Date
wangliwen 6e4c75927e Merge remote-tracking branch 'origin/master' 2022-06-24 16:49:42 +08:00
wangliwen 8a53c3f624 包头配置 2022-06-24 16:38:36 +08:00
yitonglei 9e807ed118 Merge remote-tracking branch 'origin/master' 2022-06-24 16:37:22 +08:00
yitonglei d06b2c9ec3 1、新能力统计页面部分后台代码 2022-06-24 16:37:14 +08:00
12 changed files with 765 additions and 3 deletions

View File

@ -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<List<Map<String, Object>>> resourceAssemblerDetails(@ApiIgnore @RequestParam Map<String, Object> params){
String type = params.get("resourceType").toString();
List<Map<String,Object>> 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<List<Map<String, Object>>>().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<List<Map<String, Object>>> resourceUsedDetails(@ApiIgnore @RequestParam Map<String, Object> params){
String type = params.get("resourceType").toString();
List<Map<String,Object>> 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<List<Map<String, Object>>>().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<List<Map<String, Object>>> assemblerScoreInfo(Long id){
Object[] args = {id};
List<Map<String, Object>> 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<List<Map<String, Object>>>().ok(maps);
}
@GetMapping("/assemblerUsedTopInfo")
@ApiOperation("TOP5被调用的组件和数量")
@LogOperation("TOP5被调用的组件和数量")
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> assemblerUsedTopInfo(Long id){
return null;
}
@GetMapping("/assemblerCollectionTopInfo")
@ApiOperation("TOP5被收藏的组件和数量")
@LogOperation("TOP5被收藏的组件和数量")
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> assemblerCollectionTopInfo(Long id){
Object[] args = {id};
List<Map<String, Object>> 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<List<Map<String, Object>>>().ok(maps);
}
@GetMapping("/assemblerUsedInfo")
@ApiOperation("算法、图层、开发、业务发布量情况分布")
@LogOperation("算法、图层、开发、业务发布量情况分布")
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> assemblerUsedInfo(Long id){
return null;
}
@GetMapping("/assemblerUsedDistriInfo")
@ApiOperation("应用领域分布情况")
@LogOperation("应用领域分布情况")
public Result<List<Map<String, Object>>> assemblerUsedDistriInfo(Long id){
return null;
}
//以下是组件使用情况点击详情
@GetMapping("/assemblerUseTopInfo")
@ApiOperation("TOP5使用组件")
@LogOperation("TOP5使用组件")
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> assemblerUseTopInfo(Long id){
return null;
}
@GetMapping("/assemblerUseInfo")
@ApiOperation("使用组件数量分布(算法、图层、开发、业务")
@LogOperation("使用组件数量分布(算法、图层、开发、业务")
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> assemblerUseInfo(Long id){
return null;
}
@GetMapping("/assemblerUseDistriInfo")
@ApiOperation("用组件应用领域分布情况")
@LogOperation("用组件应用领域分布情况")
public Result<List<Map<String, Object>>> assemblerUseDistriInfo(Long id){
return null;
}
@GetMapping("/assemblerUseScoreTopInfo")
@ApiOperation("使用组件评分top5")
@LogOperation("使用组件评分top5")
public Result<List<Map<String, Object>>> 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<List<Map<String, Object>>> assemblerCarDetail(@ApiIgnore @RequestParam Map<String, Object> params){
List<Map<String,Object>> result = resourceService.assemblerCarDetail(params);
return new Result<List<Map<String,Object>>>().ok(result);
}
}

View File

@ -109,4 +109,14 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map> selectTopFiveComponentServiceApplications();
List<Map> selectTopFiveComponentServiceScore();
List<Map> selectResourceNumAsType(Map<String, Object> params);
Integer selectResourceCarNum(Map params);
Integer selectResourceCollectionNum(Map params);
Integer selectResourceBrowseNum(Map params);
Integer selectResourceRelNum(Map params);
Integer selectResourceShare(Map params);
// List<Map<String,Object>> selectDeptList(Map params);
List<Map<String,Object>> selectResurceCarDetails(Map params);
}

View File

@ -83,4 +83,14 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object componentServiceRank(String type);
Integer getProjectPlace();
List<Map<String,Object>> resourceBusinessDetails(Map<String,Object> map);
List<Map<String,Object>> resourceBusinessUseDetails(Map<String,Object> map);
List<Map<String,Object>> resourceDatasUseDetails(Map<String,Object> map);
//List<Map<String,Object>> selectDeptList(Map<String,Object> params);
List<Map<String,Object>> resourceApplicationDetails(Map<String,Object> params);
List<Map<String,Object>> resourceInfrastructureDetails(Map<String,Object> params);
List<Map<String,Object>> resourceDatasDetails(Map<String,Object> params);
List<Map<String,Object>> resourceKnowledgeDetails(Map<String,Object> params);
List<Map<String,Object>> assemblerCarDetail(Map<String,Object> params);
}

View File

@ -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;
@ -856,4 +858,292 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public Integer getProjectPlace() {
return this.projectPlace;
}
@Override
public List<Map<String,Object>> resourceBusinessDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
List<Map> 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<Map<String, Object>> 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<Void> 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<Void> 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<Void> 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<Void> 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<Void> 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<Void> all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02, voidCompletableFuture03,voidCompletableFuture04,voidCompletableFuture05);
all.join();
return result;
}
@Override
public List<Map<String, Object>> resourceApplicationDetails(Map<String,Object> params){
List<Map<String, Object>> 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<Map<String, Object>> 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<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> { //应用浏览数量
result.forEach(r -> {
Object[] qu = {r.get("deptId")};
Integer integer = baseDao.selectResourceBrowseNum(params);
r.put("resourceBrowseNum", integer);
});
});
CompletableFuture<Void> voidCompletableFuture02 = CompletableFuture.runAsync(() -> { //应用收藏量
result.forEach(r -> {
Object[] qu = {r.get("deptId")};
Integer integer = baseDao.selectResourceCarNum(params);
r.put("resourceCarNum", integer);
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02);
all.join();
return result;
}
@Override
public List<Map<String,Object>> resourceInfrastructureDetails(Map<String,Object> params){
List<Map<String, Object>> 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<Map<String, Object>> 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<Void> resourceCollectionNum01 = CompletableFuture.runAsync(() -> {//被申请数量 resourceCarNum
result.forEach(r -> {
Integer integer = baseDao.selectResourceCarNum(params);
r.put("resourceCarNum", integer);
});
});
CompletableFuture<Void> resourceCollectionNum02 = CompletableFuture.runAsync(() -> {//被浏览数量
result.forEach(r -> {
Integer integer = baseDao.selectResourceBrowseNum(params);
r.put("resourceBrowseNum", integer);
});
});
CompletableFuture<Void> resourceCollectionNum03 = CompletableFuture.runAsync(() -> {//被收藏数量
result.forEach(r -> {
Integer integer = baseDao.selectResourceCollectionNum(params);
r.put("resourceCollectionNum", integer);
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceCollectionNum01, resourceCollectionNum02, resourceCollectionNum03);
all.join();
return result;
}
@Override
public List<Map<String,Object>> resourceDatasDetails(Map<String,Object> params){
List<Map<String, Object>> 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<Map<String, Object>> 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<Void> resourceCarNum = CompletableFuture.runAsync(() -> { //被申请数量
result.forEach(re -> {
Integer integer = baseDao.selectResourceCarNum(params);
re.put("resourceCarNum", integer);
});
});
CompletableFuture<Void> resourceBrowseNum = CompletableFuture.runAsync(() -> { //被浏览数量
result.forEach(re -> {
Integer integer = baseDao.selectResourceBrowseNum(params);
re.put("resourceBrowseNum", integer);
});
});
CompletableFuture<Void> resourceCollectionNum = CompletableFuture.runAsync(() -> { //被收藏数量
result.forEach(re -> {
Integer integer = baseDao.selectResourceCollectionNum(params);
re.put("resourceCollectionNum", integer);
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceCarNum, resourceBrowseNum, resourceCollectionNum);
all.join();
return result;
}
@Override
public List<Map<String,Object>> resourceKnowledgeDetails(Map<String,Object> params){
List<Map<String, Object>> 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<Map<String, Object>> 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<Map<String,Object>> selectDeptList(Map<String,Object> params){
// List<Map<String,Object>> list = new ArrayList<>();
// Map map = new HashMap();
// map.put("id",params.get("id"));
// Object[] id ={params.get("id")};
// //List<Map<String,Object>> ids = baseDao.selectDeptList(map);
// List<Map<String, Object>> maps = jdbcTemplate.queryForList(" SELECT id\n" +
// " FROM\n" +
// " sys_dept\n" +
// " WHERE\n" +
// " pid = ?", id);
// if(maps.size() > 0){
// for(int i =0;i<maps.size();i++){
// selectDeptList((Map)maps.get(i));
// }
// }else{
// list.add(map);
// }
//
// return list;
// }
@Override
public List<Map<String,Object>> resourceBusinessUseDetails(Map<String,Object> params){
List<Map<String,Object>> 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<Void> all = CompletableFuture.allOf(resourceCarNums);
//all.join();
return result;
}
@Override
public List<Map<String,Object>> resourceDatasUseDetails(Map<String,Object> params){
List<Map<String,Object>> 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<Map<String,Object>> assemblerCarDetail(Map<String,Object> params){
List<Map<String,Object>> 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;
}
}

View File

@ -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");
/**
* 资源上传
*/

View File

@ -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<List<SysDeptDTO>> treeList(@RequestParam(required = false,value = "模糊查询,部门名称") String keywords){
Long deptId = SecurityUser.getDeptId();
List<SysDeptDTO> deptListByPid = sysDeptService.getDeptListByPid(deptId);
treeMatch(deptListByPid,keywords);
return new Result<List<SysDeptDTO>>().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<SysDeptDTO> anyLevelCategoryList, String keyword) {
Iterator<SysDeptDTO> iter = anyLevelCategoryList.iterator();
while (iter.hasNext()) {
// 获取当前遍历到的目录
SysDeptDTO category = iter.next();
// 如果当前目录名称包含关键字则什么也不做不移除否则就看下一级
if (!category.getName().contains(keyword)) {
// 取出下一级目录集合
List<SysDeptDTO> childrenCategoryList = category.getChildren();
// 递归
if (!CollectionUtils.isEmpty(childrenCategoryList)) {
treeMatch(childrenCategoryList, keyword);
}
// 下一级目录看完了如果下一级目录全部被移除则移除当前目录
if (CollectionUtils.isEmpty(category.getChildren())) {
iter.remove();
}
}
}
}
}

View File

@ -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> {
*/
SysDeptEntity getByName(String name);
List<SysDeptEntity> getDeptListByPid(SysDeptEntity sysDeptEntity);
}

View File

@ -30,4 +30,6 @@ public interface SysDeptService extends BaseService<SysDeptEntity> {
List<Long> getSubDeptIdList(Long id);
SysDeptDTO getByName(String name);
List<SysDeptDTO> getDeptListByPid(Long id);
}

View File

@ -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<SysDeptDao, SysDeptEntit
return ConvertUtils.sourceToTarget(entity, SysDeptDTO.class);
}
/**
* 获取所有上级部门ID
*
@ -161,4 +163,30 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
pidList.add(pid);
}
@Override
public List<SysDeptDTO> getDeptListByPid(Long id) {
SysDeptEntity sysDeptEntity = baseDao.getById(id);//当前部门
SysDeptDTO sysDeptDTO = ConvertUtils.sourceToTarget(sysDeptEntity, SysDeptDTO.class);//转换为DTO
List<SysDeptEntity> sysDeptList = baseDao.getDeptListByPid(sysDeptEntity);//下级部门
List<SysDeptDTO> sysDeptDTOList = new ArrayList<>();
if(sysDeptList.size() > 0){
sysDeptList.forEach(dept->sysDeptDTOList.add(ConvertUtils.sourceToTarget(dept, SysDeptDTO.class)));
for(int i = 0; i<sysDeptList.size(); i++){
List<SysDeptDTO> list = getDeptListByPid(sysDeptList.get(i).getId());
sysDeptDTOList.get(i).setChildren(list);
}
sysDeptDTO.setChildren(sysDeptDTOList);
sysDeptDTOList.add(sysDeptDTO);
}else{
sysDeptDTOList.add(sysDeptDTO);
}
return sysDeptDTOList;
}
}

View File

@ -1 +1 @@
baotou.hlsurl=http://10.110.205.1:18088/server/device/hisdeviceapplylist/url/%s
baotou.hlsurl=http://172.16.10.11:8088/server/device/hisdeviceapplylist/url/%s

View File

@ -938,4 +938,145 @@
LIMIT 5
</select>
<select id="selectResourceNumAsType" parameterType="java.util.Map" resultType="java.util.Map">
SELECT COUNT(b.id) AS resourceNum,
a.id AS deptId,
a.name AS deptName,
SUM(b.visits) AS visits
FROM
sys_dept a
INNER JOIN
tb_data_resource b
ON
a.id = b.dept_id
WHERE
b.del_flag = 0
AND
b.type = '组件服务'
<if test="id != null and id != ''">
AND (a.pids LIKE concat(concat('%',#{id}),'%') OR a.id = #{id})
</if>
GROUP BY
a.name,a.id
ORDER BY
a.name,a.id
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectResourceCarNum" parameterType="java.util.Map" resultType="integer">
SELECT COUNT(a.id) as resourceCarNum
FROM
tb_resource_car a
INNER JOIN
tb_data_resource b
ON
a.resource_id = b.id
WHERE
a.del_flag = 0
<if test="id != null and id != ''">
and b.dept_id = #{id}
</if>
<if test="resourceType != null and resourceType != ''">
AND b.type = #{resourceType}
</if>
</select>
<select id="selectResourceCollectionNum" parameterType="java.util.Map" resultType="integer">
SELECT COUNT(a.id) as resourceCollectionNum
FROM
tb_resource_collection a
INNER JOIN
tb_data_resource b
ON
a.resource_id = b.id
WHERE
a.del_flag = 0
<if test="id != null and id != ''">
and b.dept_id = #{id}
</if>
<if test="resourceType != null and resourceType != ''">
AND b.type = #{resourceType}
</if>
</select>
<select id="selectResourceBrowseNum" parameterType="java.util.Map" resultType="integer">
SELECT COUNT(a.id) as resourceBrowseNum
FROM
tb_resource_browse a
INNER JOIN
tb_data_resource b
ON
a.resource_id = b.id
WHERE
a.state = 0
<if test="id != null and id != ''">
and b.dept_id = #{id}
</if>
<if test="resourceType != null and resourceType != ''">
AND b.type = #{resourceType}
</if>
</select>
<select id="selectResourceRelNum" parameterType="java.util.Map" resultType="integer">
SELECT COUNT(a.key_id) as resourceBrowseNum
FROM
tb_data_resource_rel a
INNER JOIN
tb_data_resource b
ON
a.reference_id = b.id
WHERE
a.del_flag = 0
<if test="id != null and id != ''">
and b.dept_id = #{id}
</if>
<if test="resourceType != null and resourceType != ''">
AND b.type = #{resourceType}
</if>
</select>
<select id="selectResourceShare" parameterType="java.util.Map" resultType="integer">
SELECT COUNT(id) AS nums
FROM
tb_data_resource
WHERE
del_flag = 0
<if test="id != null and id != ''">
and
dept_id = #{id}
</if>
<if test="resourceType != null and resourceType != ''">
AND
type = #{resourceType}
</if>
<if test="shareCondition != null and shareCondition != ''">
AND
share_condition = #{shareCondition}
</if>
</select>
<select id="selectResurceCarDetails" parameterType="java.util.Map" resultType="java.util.Map">
SELECT COUNT(a.id) AS resourceCarNum,
c.name as deptName
FROM
tb_resource_car a
INNER JOIN
sys_user b
ON
a.user_id = b.id
INNER JOIN
sys_dept c
ON
b.dept_id = c.id
INNER JOIN
tb_data_resource d
ON
a.resource_id = d.id
where
(c.id = #{id} or c.pids LIKE CONCAT('%',CONCAT(#{id},'%')))
AND
d.type = #{resourceType}
group by
c.name
order by
c.name
LIMIT ${pageNum}, ${pageSize}
</select>
</mapper>

View File

@ -34,4 +34,7 @@
where t1.name = #{name} LIMIT 1
</select>
<select id="getDeptListByPid" resultType="io.renren.modules.sys.entity.SysDeptEntity">
select * from sys_dept where pid = #{id};
</select>
</mapper>