This commit is contained in:
wangliwen 2022-08-15 10:23:10 +08:00
parent e602317a7a
commit 5b5ec4d05d
1 changed files with 83 additions and 164 deletions

View File

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