Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-08-15 10:23:39 +08:00
commit cf13470a00
5 changed files with 166 additions and 165 deletions

View File

@ -605,5 +605,12 @@ public class ResourceController {
return new Result<>().ok(resourceService.selectAppList(params));
}
@GetMapping("/getCountByFuzzyQuery")
@ApiOperation("获取各类资源模糊查询总数")
@LogOperation("获取各类资源模糊查询总数")
public Result getCountByFuzzyQuery(@RequestParam String keyWorld) {
return new Result<>().ok(resourceService.getCountByFuzzyQuery(keyWorld));
}
}

View File

@ -174,4 +174,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map> selectAppList(@Param("pageNum") int pageNum, @Param("type") Integer type);
String selectPicByResId(@Param("id") String id);
List<Map> selectTypeCountByName(@Param("keyWorld") String keyWorld);
}

View File

@ -136,4 +136,6 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
PageData<Map<String,Object>> resourceInstallationOrDataResourceDetails(Map<String, Object> params);
Object selectAppList(Map params);
Object getCountByFuzzyQuery(String keyWorld);
}

View File

@ -88,12 +88,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
/**
* 公共http客户端
*/
private static final OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.connectionPool(new ConnectionPool(CPU_NUM * 2, 2, TimeUnit.MINUTES))
.retryOnConnectionFailure(false)
.build();
private static final OkHttpClient client = new OkHttpClient().newBuilder().connectTimeout(1, TimeUnit.MINUTES).readTimeout(1, TimeUnit.MINUTES).connectionPool(new ConnectionPool(CPU_NUM * 2, 2, TimeUnit.MINUTES)).retryOnConnectionFailure(false).build();
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
@ -476,25 +471,19 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
case "DESC": // total 倒序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
}
).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x ->
Long.valueOf(x.get("id").toString())
).limit(pageSize).collect(Collectors.toList());
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
}).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp;
}).get();
break;
case "ASC": // total 升序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
return Long.valueOf(string);
}
)).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
Long.valueOf(x.get("id").toString())
).limit(pageSize).collect(Collectors.toList());
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
return Long.valueOf(string);
})).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp;
}).get();
break;
@ -524,13 +513,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultPage.setRecords(new ArrayList<>());
resultPage.setTotal(0);
} else {
List<ResourceDTO> recordLists = resourceDTOS.stream()
.skip((pageNum - 1) * pageSize).limit(pageSize)
.map(dto_ -> {
ResourceDTO get = this.selectWithAttrs(dto_.getId());
BeanUtils.copyProperties(get, dto_);
return dto_;
}).collect(Collectors.toList());
List<ResourceDTO> recordLists = resourceDTOS.stream().skip((pageNum - 1) * pageSize).limit(pageSize).map(dto_ -> {
ResourceDTO get = this.selectWithAttrs(dto_.getId());
BeanUtils.copyProperties(get, dto_);
return dto_;
}).collect(Collectors.toList());
resultPage.setRecords(recordLists);
resultPage.setTotal(resourceDTOS.size());
}
@ -541,9 +528,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public List<AttrEntity> selectAttrsByResourceId(Long resourceId) {
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
wrapper.eq("data_resource_id", resourceId)
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.orderByDesc("attr_type");
wrapper.eq("data_resource_id", resourceId).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).orderByDesc("attr_type");
return attrDao.selectList(wrapper);
}
@ -555,42 +540,40 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
case TSINGTAO_XHA: { // 青岛西海岸
CompletableFuture allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
List<Long> result = new CopyOnWriteArrayList<>();
CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网
String url = tsingtao_xhaProperties.getCamCount();
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) {
result.add(jsonObject.getLongValue("body"));
}
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
CompletableFuture cloud = CompletableFuture.runAsync(() -> { // 云脑专网
String url = tsingtao_xhaProperties.getCamCount();
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) {
result.add(jsonObject.getLongValue("body"));
}
}, executor);
CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网
String url = tsingtao_xhaProperties.getLocalcam();
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) {
result.add(jsonObject.getLongValue("body"));
}
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
}
}, executor);
CompletableFuture local = CompletableFuture.runAsync(() -> { // 金宏网
String url = tsingtao_xhaProperties.getLocalcam();
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) {
result.add(jsonObject.getLongValue("body"));
}
}, executor);
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
}
}, executor);
CompletableFuture all = CompletableFuture.allOf(cloud, local);
all.join();
return result.stream().filter(Objects::nonNull).findAny().orElse(0L);
@ -638,11 +621,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
re.add(new HashMap<String, Object>() {
{
QueryWrapper<CameraChannel> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("check_status", 1)
.ne("gps_x", "")
.ne("gps_y", "")
.isNotNull("gps_x")
.isNotNull("gps_y");
queryWrapper.eq("check_status", 1).ne("gps_x", "").ne("gps_y", "").isNotNull("gps_x").isNotNull("gps_y");
put("count", cameraChannelMapper.selectCount(queryWrapper) + "");
put("type", "基础设施");
}
@ -699,8 +678,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
ResourceEntity entity = new ResourceEntity();
entity.setVisits((resourceEntity.getVisits() == null ? 0 : resourceEntity.getVisits()) + 1);
UpdateWrapper<ResourceEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
updateWrapper.lambda().eq(ResourceEntity::getId, resourceEntity.getId()).eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
resourceDao.update(entity, updateWrapper);
Integer num = jdbcTemplate.queryForObject("SELECT round(tb_data_resource_assignmark.total) FROM tb_data_resource_assignmark WHERE id =" + id, Integer.class);
@ -782,21 +760,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString()));
//区级要根据行政区划多加一层结构
List<CompletableFuture> tasks =
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
CompletableFuture task = CompletableFuture.runAsync(() -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
map.put("total", integer);
item.getValue().forEach(item1 -> item1.remove("type"));
map.put("dataList", item.getValue());
if (integer != 0) {
resultList.add(map);
}
}, executor);
return task;
}).collect(Collectors.toList());
List<CompletableFuture> tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
CompletableFuture task = CompletableFuture.runAsync(() -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
map.put("total", integer);
item.getValue().forEach(item1 -> item1.remove("type"));
map.put("dataList", item.getValue());
if (integer != 0) {
resultList.add(map);
}
}, executor);
return task;
}).collect(Collectors.toList());
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join();
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
@ -1062,8 +1039,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object getApplyCameraList(Long instanceId) {
QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("instance_id", instanceId)
.eq("approve_status", "通过");
queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过");
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
ArrayList cameraList = new ArrayList();
applicationEntities.forEach(index -> {
@ -1137,7 +1113,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
do {
final long timestamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
int page = pageIndex.getAndIncrement();
logger.info("处理:{}分页{}", index, page);
logger.info("处理:{} 分页{}", index, page);
task.add(CompletableFuture.supplyAsync(() -> {
try {
logger.info("分页任务处理:{}分页{} 时间--> {}", index, page, timestamp);
@ -1149,19 +1125,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
String bizContent = bizContentParam.toJSONString();
logger.info("biz_content参数{}", bizContent);
// 通过FormBody对象构建Builder来添加表单参数
FormBody.Builder signFormBody = new FormBody.Builder().add("app_id", appId)
.add("interface_id", methodId).
add("version", version).
add("timestamp", String.valueOf(timestamp)).
add("origin", origin).
add("charset", charset).
add("biz_content", bizContent);
logger.info("{}分页{}对接知识库数据请求参数:{}", index, page, signFormBody.build().contentType().toString());
FormBody.Builder signFormBody = new FormBody.Builder().add("app_id", appId).add("interface_id", methodId).add("version", version).add("timestamp", String.valueOf(timestamp)).add("origin", origin).add("charset", charset).add("biz_content", bizContent);
logger.info("{} 分页 {} 对接知识库数据请求参数:{}", index, page, signFormBody.build().contentType().toString());
Request signRequest = new Request.Builder().url(sign).post(signFormBody.build()).build();
Response signResponse = client.newCall(signRequest).execute();
String signResult = signResponse.body().string();
logger.info("{}分页signResult数据{}", page, signResult);
logger.info("{} 分页signResult数据{}", page, signResult);
JSONObject signJsonObject = JSON.parseObject(signResult);
if (!signJsonObject.containsKey("data")) {
logger.info("获取sign异常{}", signResult);
@ -1202,7 +1172,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
}, executor).thenAcceptAsync(list -> {
logger.info("知识库数据量:{}", list.size());
if (list.isEmpty()) {
if (list.isEmpty() || list.size() < pageSize) {
end.set(false);
}
customThreadPool.submit(() -> {
@ -1258,9 +1228,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
customThreadPool.shutdown();
}, executor));
try {
Thread.sleep(300L);
Thread.sleep(100L); // 防止任务运行过快无法跳出循环
} catch (InterruptedException e) {
throw new RuntimeException(e);
logger.info("知识库同步异常", e);
// throw new RuntimeException(e);
}
} while (end.get() || pageIndex.get() < maxPage.get());
return task;
@ -1295,20 +1266,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map<String, Object>> result2;
if (Long.parseLong(params.get("id").toString()) == 0) {
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" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n");
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" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n");
} else {
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 INSTR(b.pids,?))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n", pas);
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 INSTR(b.pids,?))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas);
}
if (!result2.isEmpty()) {
@ -1386,18 +1346,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map<String, Object>> result2;
if (Long.parseLong(params.get("id").toString()) == 0) {
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" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n");
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" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n");
} else {
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", pas);
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", pas);
}
if (!result2.isEmpty()) {
@ -1487,18 +1438,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map<String, Object>> result2;
if (Long.parseLong(params.get("id").toString()) == 0) {
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" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n");
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" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n");
} else {
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 INSTR(b.pids,?))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n", pas);
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 INSTR(b.pids,?))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas);
}
if (!result2.isEmpty()) {
@ -1544,18 +1486,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map<String, Object>> result2;
if (Long.parseLong(params.get("id").toString()) == 0) {
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" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n");
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" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n");
} else {
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 INSTR(b.pids,?))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n", pas);
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 INSTR(b.pids,?))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas);
}
@ -1601,20 +1534,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Object[] pas = {params.get("id"), params.get("id")};
if (Long.parseLong(params.get("id").toString()) == 0) {
result = jdbcTemplate.queryForList(
"SELECT COUNT(a.id) AS resourceNum,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" +
"GROUP BY b.name\n" +
"ORDER BY b.name ");
result = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,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" + "GROUP BY b.name\n" + "ORDER BY b.name ");
} else {
result = jdbcTemplate.queryForList(
"SELECT COUNT(a.id) AS resourceNum,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 INSTR(b.pids,?))\n" +
"GROUP BY b.name\n" +
"ORDER BY b.name ", pas);
result = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,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 INSTR(b.pids,?))\n" + "GROUP BY b.name\n" + "ORDER BY b.name ", pas);
}
List<List<Map<String, Object>>> partition = Lists.partition(result, pageSize);
@ -1710,9 +1632,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public List<Map<String, Object>> assemblerCarDetail(Map<String, Object> params) {
List<Map<String, Object>> result;
Object[] ps = {params.get("resourceType"), params.get("id"), (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()), Integer.parseInt(params.get("limit").toString())};
result = jdbcTemplate.queryForList("SELECT a.* FROM tb_resource_car a INNER JOIN sys_user b ON a.creator = b.id " +
"INNER JOIN tb_data_resource d ON a.resource_id = d.id WHERE a.del_flag = 0 AND d.type = ? AND " +
"d.dept_id = ? AND d.del_flag = 0 ORDER BY a.create_date DESC LIMIT ?,?", ps);
result = jdbcTemplate.queryForList("SELECT a.* FROM tb_resource_car a INNER JOIN sys_user b ON a.creator = b.id " + "INNER JOIN tb_data_resource d ON a.resource_id = d.id WHERE a.del_flag = 0 AND d.type = ? AND " + "d.dept_id = ? AND d.del_flag = 0 ORDER BY a.create_date DESC LIMIT ?,?", ps);
return result;
}
@ -1903,8 +1823,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));
} else {
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey()));
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null
&& resourceMountApplyDTO.getResourceDTO().getId() != null) {
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null && resourceMountApplyDTO.getResourceDTO().getId() != null) {
resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId());
if (resourceMountApplyDTO.getResourceId() != null) {
ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId());
@ -1996,7 +1915,64 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
return result;
}
@Override
public Object getCountByFuzzyQuery(String keyWorld) {
ArrayList<Map> resultList = new ArrayList<>();
CompletableFuture<Void> DBresourceCount = CompletableFuture.runAsync(() -> resultList.addAll(resourceDao.selectTypeCountByName(keyWorld)));
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO_XHA:
break;
case TSINGTAO: {
CompletableFuture<Void> dataResourceCount = CompletableFuture.runAsync(() -> { //数据资源
//青岛市局数据资源
TsingtaoDataResourceService tsingtaoDataResourceService = new TsingtaoDataResourceService();
GetDataResourceListDto getDataResourceListDto = new GetDataResourceListDto().setPageNum(1).setPageSize(5).setServiceName(keyWorld);
HashMap dataResource = (HashMap) tsingtaoDataResourceService.getDataResource(getDataResourceListDto);
resultList.add(new HashMap<String, Object>() {
{
put("count", null == dataResource ? "0" : dataResource.get("rows") + "");
put("type", "数据资源");
}
});
}, executor);
CompletableFuture<Void> infrastructureCount = CompletableFuture.runAsync(() -> { //基础设施
HashMap<Object, Object> queryMap = new HashMap<>();
queryMap.put("cameraName",keyWorld);
Integer countNew = cameraChannelMapper.selectByParentIdCountNew(queryMap, null, "");
resultList.add(new HashMap<String, Object>() {
{
put("count", countNew + "");
put("type", "基础设施");
}
});
}, executor);
CompletableFuture<Void> all = CompletableFuture.allOf(DBresourceCount, dataResourceCount, infrastructureCount);
all.join();
}
break;
default:
break;
}
//未查到的类型返回数量0
List<String> temp = new ArrayList<>();
resultList.forEach(map -> temp.add(map.get("type").toString()));
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> {
Map<String, Object> nullMap = new HashMap<String, Object>() {
{
put("count", "0");
put("type", index);
}
};
resultList.add(nullMap);
});
return resultList;
}
}

View File

@ -605,7 +605,7 @@
</if>
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
LEFT JOIN sys_region sr ON sd.district = sr.id
ORDER BY sd.type, sr.sort
ORDER BY sd.type, sr.sort, sd.sort
) temp1
WHERE
1 = 1
@ -1531,4 +1531,18 @@
AND tdr.id = #{id}
AND tda.del_flag = 0
</select>
<select id="selectTypeCountByName" resultType="java.util.Map">
SELECT
type,
count(id) AS "count"
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
<if test="keyWorld != null and keyWorld != ''">
AND MATCH (name) AGAINST ( #{keyWorld} IN BOOLEAN MODE)
</if>
AND type != '赋能案例'
GROUP BY type
ORDER BY type
</select>
</mapper>