数据资源统计修改

This commit is contained in:
dinggang 2022-06-24 19:54:20 +08:00
parent bf5628d97f
commit f4d0001b85
2 changed files with 82 additions and 43 deletions

View File

@ -388,7 +388,7 @@ public class CensusControllerV2 {
});
result.add(new HashMap<String, Object>() {
{
put("amount", 0l);
put("amount", 0L);
put("type", "总申请次数");
}
});

View File

@ -15,6 +15,8 @@ import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.resource.dao.AttrDao;
import io.renren.modules.resource.dao.ResourceDao;
import io.renren.modules.resource.dataResource.domain.TsingtaoDataResourceService;
import io.renren.modules.resource.dto.GetDataResourceListDto;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity;
@ -377,7 +379,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
logger.error("青岛西海岸失败", exception);
}
});
CompletableFuture.allOf(cloud, local);
CompletableFuture all = CompletableFuture.allOf(cloud, local);
all.join();
return result_.stream().filter(index -> index != null).findAny().orElse(0l);
}).thenAccept(sum -> {
re.add(new HashMap<String, Object>() {
@ -387,8 +390,44 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
});
});
OkHttpClient client = new OkHttpClient();
Long total = 0L;
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
total = jsonObject.getJSONObject("data").getLongValue("total");
Long finalTotal = total;
re.add(new HashMap<String, Object>() {
{
put("amount", finalTotal);
put("type", "数据资源");
}
});
}
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
}
allAmount.join();
}
break;
case TSINGTAO: {
//青岛市局数据资源
TsingtaoDataResourceService tsingtaoDataResourceService = new TsingtaoDataResourceService();
GetDataResourceListDto getDataResourceListDto = new GetDataResourceListDto().setPageNum(1).setPageSize(5);
HashMap dataResource = (HashMap) tsingtaoDataResourceService.getDataResource(getDataResourceListDto);
re.add(new HashMap<String, Object>() {
{
put("count", dataResource.get("rows") + "");
put("type", "数据资源");
}
});
}
break;
}
resultMap.put("total", re);
return resultMap;
@ -860,8 +899,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceBusinessDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
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()));
@ -871,16 +910,16 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
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};
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" +
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" +
"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);
"LIMIT ?,?", pas);
result.addAll(result2);
@ -937,27 +976,27 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
});
//还缺少被调用总数
CompletableFuture<Void> all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02, voidCompletableFuture03,voidCompletableFuture04,voidCompletableFuture05);
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){
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};
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" +
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" +
"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);
"LIMIT ?,?", pas);
result.addAll(result2);
CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> { //应用浏览数量
result.forEach(r -> {
@ -982,20 +1021,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceInfrastructureDetails(Map<String,Object> params){
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};
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" +
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" +
"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);
"LIMIT ?,?", pas);
result.addAll(result2);
CompletableFuture<Void> resourceCollectionNum01 = CompletableFuture.runAsync(() -> {//被申请数量 resourceCarNum
@ -1026,20 +1065,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceDatasDetails(Map<String,Object> params){
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};
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" +
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" +
"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);
"LIMIT ?,?", pas);
result.addAll(result2);
CompletableFuture<Void> resourceCarNum = CompletableFuture.runAsync(() -> { //被申请数量
@ -1070,26 +1109,26 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceKnowledgeDetails(Map<String,Object> params){
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};
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" +
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" +
"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);
"LIMIT ?,?", pas);
result.addAll(result2);
return result;
}
// @Override
// @Override
// public List<Map<String,Object>> selectDeptList(Map<String,Object> params){
// List<Map<String,Object>> list = new ArrayList<>();
// Map map = new HashMap();
@ -1112,8 +1151,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
// return list;
// }
@Override
public List<Map<String,Object>> resourceBusinessUseDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
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);
@ -1125,8 +1164,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceDatasUseDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
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);
@ -1134,15 +1173,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@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())};
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);
"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;
}