From 52c4715b8fa1e4276eef809c1a55de10c69828cb Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Fri, 29 Jul 2022 10:43:29 +0800 Subject: [PATCH] .. --- .../controller/SysNoticeController.java | 11 +- .../controller/ResourceController.java | 39 ++- .../resource/service/ResourceService.java | 3 +- .../service/impl/ResourceServiceImpl.java | 254 ++++++++---------- .../security/oauth2/ShiroSessionManager.java | 1 + .../resources/domain/tsingtao-xha.properties | 2 +- 6 files changed, 134 insertions(+), 176 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeController.java b/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeController.java index 80bc16e8..ba3a3980 100644 --- a/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeController.java +++ b/renren-admin/src/main/java/io/renren/modules/notice/controller/SysNoticeController.java @@ -29,7 +29,6 @@ import java.util.Arrays; import java.util.Date; import java.util.Map; - /** * 通知管理 * @@ -50,10 +49,10 @@ public class SysNoticeController { @GetMapping("page") @ApiOperation("分页") @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 = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") + @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 = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") }) // @RequiresPermissions("sys:notice:all") public Result> page(@ApiIgnore @RequestParam Map params) { @@ -165,7 +164,7 @@ public class SysNoticeController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") -// @RequiresPermissions("sys:notice:all") + //@RequiresPermissions("sys:notice:all") public Result delete(@RequestBody Long[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index d52cd427..787ce2ad 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -237,7 +237,7 @@ public class ResourceController { //@RequiresPermissions("resource:resource:save") public Result save(@RequestBody ResourceDTO dto, @RequestParam String source) { // 效验数据 - logger.info("source:" + source); + logger.info("source:{}", source); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); if ("f".equals(source)) { dto.setDelFlag(2); // 来自前端页面 走审批流程 @@ -257,7 +257,7 @@ public class ResourceController { public Result importResource(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) { List> dept = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept"); - logger.info("上传文件:" + uploadFile.getOriginalFilename()); + logger.info("上传文件:{}" , uploadFile.getOriginalFilename()); String format = sdf.format(new Date()); File folder = new File(uploadPath + "upload" + File.separator + format); logger.info(folder.getPath()); @@ -266,29 +266,20 @@ public class ResourceController { } // 对上传的文件重命名,避免文件重名 String oldName = uploadFile.getOriginalFilename(); - String newName = UUID.randomUUID().toString() - + oldName.substring(oldName.lastIndexOf(".")); + String newName = UUID.randomUUID() + oldName.substring(oldName.lastIndexOf(".")); try { // 文件保存 File file = new File(folder, newName); uploadFile.transferTo(file); Optional deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName)); - CompletableFuture.runAsync(() -> { - EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync(); - }, executor); - CompletableFuture.runAsync(() -> { - EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync(); - }, executor); - CompletableFuture.runAsync(() -> { - EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync(); - }, executor); - CompletableFuture.runAsync(() -> { - EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync(); - }, executor); + CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync(), executor); + CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync(), executor); + CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync(), executor); + CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync(), executor); } catch (IOException e) { return new Result().error(e.getMessage()); } - return new Result().ok(LocalDateTime.now().toString()); + return new Result().ok(LocalDateTime.now().toString()); } @PutMapping("/update") @@ -318,7 +309,7 @@ public class ResourceController { @LogOperation("资源转发") public Result ZywMessage() { String url = "http://15.72.158.81/zyjk/ZywMessage.asmx"; - String parame = "\n" + + String param = "\n" + "\n" + " \n" + " \n" + @@ -326,11 +317,11 @@ public class ResourceController { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("SOAPAction", "http://tempuri.org/ZywMessagePort"); requestHeaders.setContentType(MediaType.TEXT_XML); - HttpEntity requestEntity = new HttpEntity(parame, requestHeaders); + HttpEntity requestEntity = new HttpEntity<>(param, requestHeaders); try { String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody(); String json = body.substring(body.indexOf("{"), body.indexOf("}") + 1); - HashMap map = JSONObject.parseObject(json, HashMap.class); + HashMap map = JSON.parseObject(json, HashMap.class); return new Result().ok(map); } catch (Exception e) { return new Result().ok(new HashMap() {{ @@ -372,13 +363,13 @@ public class ResourceController { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort"); requestHeaders.setContentType(new MediaType("text", "xml", Charset.forName("utf-8"))); - HttpEntity requestEntity = new HttpEntity(parame, requestHeaders); + HttpEntity requestEntity = new HttpEntity<>(parame, requestHeaders); try { String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody(); String startTag = ""; String endTag = ""; String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag)); - HashMap result = JSONObject.parseObject(json, HashMap.class); + HashMap result = JSON.parseObject(json, HashMap.class); List rows = (List) result.get("data"); List objects = rows.stream() @@ -520,8 +511,8 @@ public class ResourceController { @GetMapping("/selectTotalByDept") @ApiOperation("按照资源类型统计本部门发布的资源") @LogOperation("按照资源类型统计本部门发布的资源") - public Result selectTotalByDept() { - return new Result().ok(resourceService.selectTotalByDept()); + public Result> selectTotalByDept() { + return new Result>().ok(resourceService.selectTotalByDept()); } @GetMapping("/getApplyByDept") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index d615af06..ec771dc8 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -7,6 +7,7 @@ import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.ResourceEntity; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -111,7 +112,7 @@ public interface ResourceService extends CrudService params); - Object selectTotalByDept(); + HashMap selectTotalByDept(); Object getApplyByDept(Map params); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 54e09203..49f2d5e6 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -81,8 +81,8 @@ import java.util.stream.Collectors; */ @Service public class ResourceServiceImpl extends CrudServiceImpl implements ResourceService { - private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors(); - private static final ExecutorService executor = Executors.newWorkStealingPool(cpuNUm * 3); + private static final Integer CPU_NUM = Runtime.getRuntime().availableProcessors(); + private static final ExecutorService executor = Executors.newWorkStealingPool(CPU_NUM * 3); /** * 公共http客户端 @@ -90,14 +90,14 @@ public class ResourceServiceImpl extends CrudServiceImpl idList = jsonArray.toJavaList(Long.class); @@ -340,7 +342,7 @@ public class ResourceServiceImpl extends CrudServiceImpl common(Page resultPage, List selectDTOPageSpecilTotal, ResourceDTO resourceDTO, String orderField, String orderType, Integer pageNum, Integer pageSize) { if (resourceDTO.getInfoList().isEmpty()) { @@ -533,15 +532,10 @@ public class ResourceServiceImpl extends CrudServiceImpl resultMap = new HashMap<>(); List re = resourceDao.selectTypeCount(null); - /*//2022-07-05,ytl修改 start - re.removeIf(r -> { - return org.apache.commons.lang3.StringUtils.equals(r.get("type").toString(), "基础设施"); - }); - //2022-07-05,ytl修改 end*/ switch (Constant.ProjectPlace.getByFlag(projectPlace)) { case TSINGTAO_XHA: { // 青岛西海岸 CompletableFuture allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 - List result_ = new CopyOnWriteArrayList<>(); + List result = new CopyOnWriteArrayList<>(); CompletableFuture cloud = CompletableFuture.runAsync(() -> { // 云脑专网 String url = tsingtao_xhaProperties.getCloudcam(); @@ -551,7 +545,7 @@ public class ResourceServiceImpl extends CrudServiceImpl { - re.add(new HashMap() { - { - put("count", sum + ""); - put("type", "基础设施"); - } - }); - }); - Long total = 0L; + return result.stream().filter(Objects::nonNull).findAny().orElse(0L); + }).thenAccept(sum -> re.add(new HashMap() { + { + put("count", sum + ""); + put("type", "基础设施"); + } + })); + Long total; Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { @@ -642,6 +631,8 @@ public class ResourceServiceImpl extends CrudServiceImpl temp = new ArrayList<>(); re.forEach(map -> temp.add(map.get("type").toString())); @@ -730,13 +721,13 @@ public class ResourceServiceImpl extends CrudServiceImpl resultPage = (Page) this.selectMostPopular(object); do { - resultPage.getRecords().forEach(p->{ + resultPage.getRecords().forEach(p -> { //如果集合中不存在,则进行添加 - if (!page.getRecords().contains(p)){ + if (!page.getRecords().contains(p)) { page.getRecords().add(p); } }); - }while (page.getRecords().size() < 9); + } while (page.getRecords().size() < 9); //for (int i = 0; page.getRecords().size() < 9; i++) { // for (int j = 0; j < page.getRecords().size(); j++) { // if (!page.getRecords().get(j).getId().equals(resultPage.getRecords().get(i).getId())) { @@ -763,7 +754,7 @@ public class ResourceServiceImpl extends CrudServiceImpl resultList = new CopyOnWriteArrayList<>(); HashMap resourceMap = new HashMap<>(); @@ -1054,7 +1045,7 @@ public class ResourceServiceImpl extends CrudServiceImpl selectDTOPageSpecilTotal(ResourceDTO resourceDTO) { return resourceDao.selectDTOPageSpecilTotal(resourceDTO); } @@ -1126,12 +1117,12 @@ public class ResourceServiceImpl extends CrudServiceImpl knowledgeUUID = jdbcTemplate.queryForList("SELECT note1 FROM tb_data_resource WHERE type ='知识库' AND note1 IS NOT NULL FOR UPDATE;", String.class).stream().distinct().collect(Collectors.toList()); - final int pageSize = cpuNUm * 10; + final int pageSize = CPU_NUM * 10; Arrays.stream(catalogIds).map(index -> { - logger.info("处理:" + index); + logger.info("处理:{}", index); CopyOnWriteArrayList task = new CopyOnWriteArrayList<>(); AtomicBoolean end = new AtomicBoolean(true); AtomicInteger pageIndex = new AtomicInteger(1); @@ -1139,33 +1130,39 @@ public class ResourceServiceImpl extends CrudServiceImpl { try { - logger.info("分页任务处理:" + index + " 分页{} 时间 -->" + timestamp, page); + logger.info("分页任务处理:{}分页{} 时间--> {}", index, page, timestamp); JSONObject bizContentParam = new JSONObject(); bizContentParam.put("appkey", appKey); bizContentParam.put("catalogId", index); bizContentParam.put("pageIndex", page); bizContentParam.put("pageSize", pageSize); - String bizContent_ = bizContentParam.toJSONString(); - logger.info("biz_content参数:{}", bizContent_); + 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 + "分页{}对接知识库数据请求参数:" + signFormBody.build().contentType().toString(), page); + 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数据:" + signResult, page); + logger.info("{}分页signResult数据:{}", page, signResult); JSONObject signJsonObject = JSON.parseObject(signResult); if (!signJsonObject.containsKey("data")) { - logger.info("获取sign异常:" + signResult); + logger.info("获取sign异常:{}", signResult); end.set(false); throw new RuntimeException("获取sign异常"); } if (signJsonObject.get("data") == null) { - logger.info("获取sign异常:" + signResult); + logger.info("获取sign异常:{}", signResult); end.set(false); throw new RuntimeException("获取sign异常"); } @@ -1247,7 +1244,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> resourceInfrastructureDetails(Map params) { - List> result = new CopyOnWriteArrayList<>(); + List> result; 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")}; - List> result2 = new ArrayList<>(); + List> 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" + @@ -1452,11 +1449,11 @@ public class ResourceServiceImpl extends CrudServiceImpl 0) { + if (!result2.isEmpty()) { List>> partition = Lists.partition(result2, pageSize); - result.addAll(partition.get(page)); + result = new CopyOnWriteArrayList<>(partition.get(page)); } else { - return new PageData<>(result2, result2.size()); + return new PageData<>(result2, 0); } CompletableFuture resourceCollectionNum01 = CompletableFuture.runAsync(() -> {//被申请数量 resourceCarNum @@ -1483,8 +1480,7 @@ public class ResourceServiceImpl extends CrudServiceImpl all = CompletableFuture.allOf(resourceCollectionNum01, resourceCollectionNum02, resourceCollectionNum03); all.join(); - PageData> pageData = new PageData<>(result, result2.size()); - return pageData; + return new PageData<>(result, result2.size()); } @Override @@ -1494,7 +1490,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> result2 = new ArrayList<>(); + List> 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" + @@ -1511,7 +1507,7 @@ public class ResourceServiceImpl extends CrudServiceImpl 0) { + if (!result2.isEmpty()) { List>> partition = Lists.partition(result2, pageSize); result.addAll(partition.get(page)); } else { @@ -1542,13 +1538,12 @@ public class ResourceServiceImpl extends CrudServiceImpl all = CompletableFuture.allOf(resourceCarNum, resourceBrowseNum, resourceCollectionNum); all.join(); - PageData> pageData = new PageData<>(result, result2.size()); - return pageData; + return new PageData<>(result, result2.size()); } @Override public PageData> resourceKnowledgeDetails(Map params) { - List> result = new ArrayList<>(); + List> result; 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")}; @@ -1571,100 +1566,77 @@ public class ResourceServiceImpl extends CrudServiceImpl>> partition = Lists.partition(result, pageSize); - if (result.size() > 0) { - PageData> pageData = new PageData<>(partition.get(page), result.size()); - return pageData; + if (!result.isEmpty()) { + return new PageData<>(partition.get(page), result.size()); } else { - return new PageData<>(result, result.size()); + return new PageData<>(result, 0); } } @Override public PageData> resourceBusinessUseDetails(Map params) { - List> maps = new CopyOnWriteArrayList<>(); + List> maps; Integer page = Integer.parseInt(params.get("page").toString()) - 1; Integer pageSize = Integer.parseInt(params.get("limit").toString()); Object[] ps = {params.get("id"), params.get("id")}; //获取部门列表 - List> list = new ArrayList<>(); + List> list; if (Long.parseLong(params.get("id").toString()) == 0) { - list = jdbcTemplate.queryForList("SELECT id as deptId,name AS deptName FROM sys_dept"); + list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept"); } else { - list = jdbcTemplate.queryForList("SELECT id as deptId,name AS deptName FROM sys_dept WHERE id = ? OR INSTR(pids,?)", ps); + list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept WHERE id = ? OR INSTR(pids,?)", ps); } - if (list.size() > 0) { + if (!list.isEmpty()) { List>> partition = Lists.partition(list, pageSize); - maps.addAll(partition.get(page)); + maps = new CopyOnWriteArrayList<>(partition.get(page)); } else { - return new PageData<>(list, list.size()); + return new PageData<>(list, 0); } Map paraMap = new ConcurrentHashMap<>(); paraMap.put("resourceType", params.get("resourceType")); - //分别根据部门获取组件使用总数和调用数 - //申请数 -// CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> { -// maps.forEach(m -> { -// paraMap.put("id", m.get("deptId")); -// Map maps1 = new HashMap<>(); -// maps1 = baseDao.assemblyCarByDept(paraMap); -// if (maps1 == null) { -// m.put("resourceCarNum", 0); -// } else { -// m.put("resourceCarNum", maps1.get("carNum") == null ? 0 : maps1.get("carNum")); -// } -// }); -// }); - //本部门的应用关联的组件数量 - CompletableFuture voidCompletableFuture02 = CompletableFuture.runAsync(() -> { - maps.forEach(m -> { - paraMap.put("id", m.get("deptId")); - Map maps2 = new HashMap<>(); - maps2 = baseDao.assemblyUseByDept(paraMap); - if (maps2 == null) { - m.put("resourceUseNum", 0); - } else { - m.put("resourceUseNum", maps2.get("useNum") == null ? 0 : maps2.get("useNum")); - } - }); - }, executor); + CompletableFuture voidCompletableFuture02 = CompletableFuture.runAsync(() -> maps.forEach(m -> { + paraMap.put("id", m.get("deptId")); + Map maps2 = new HashMap<>(); + maps2 = baseDao.assemblyUseByDept(paraMap); + if (maps2 == null) { + m.put("resourceUseNum", 0); + } else { + m.put("resourceUseNum", maps2.get("useNum") == null ? 0 : maps2.get("useNum")); + } + }), executor); //还缺少组件调用数,这先用假数据代替 - CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> { - maps.forEach(m -> { - m.put("resourceCallNum", 0); - }); - }, executor); + CompletableFuture voidCompletableFuture01 = CompletableFuture.runAsync(() -> maps.forEach(m -> m.put("resourceCallNum", 0)), executor); CompletableFuture all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02); all.join(); - PageData> pageData = new PageData<>(maps, list.size()); - return pageData; + return new PageData<>(maps, list.size()); } @Override public PageData> resourceDatasUseDetails(Map params) { - List> result = new ArrayList<>(); + List> result; Integer page = Integer.parseInt(params.get("page").toString()) - 1; Integer pageSize = Integer.parseInt(params.get("limit").toString()); //查询部门列表 Object[] ps = {params.get("id"), params.get("id")}; - List> list = new ArrayList<>(); + List> list; if (Long.parseLong(params.get("id").toString()) == 0) { list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept "); } else { list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept WHERE id = ? OR INSTR(pids,?) ", ps); } - if (list.size() > 0) { + if (!list.isEmpty()) { List>> partition = Lists.partition(list, pageSize); - result.addAll(partition.get(page)); + result = new ArrayList<>(partition.get(page)); } else { - return new PageData<>(list, list.size()); + return new PageData<>(list, 0); } ConcurrentHashMap map = new ConcurrentHashMap(); map.put("resourceType", params.get("resourceType")); @@ -1679,13 +1651,12 @@ public class ResourceServiceImpl extends CrudServiceImpl> pageData = new PageData<>(result, list.size()); - return pageData; + return new PageData<>(result, list.size()); } @Override public List> assemblerCarDetail(Map params) { - List> result = new ArrayList<>(); + List> 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 " + @@ -1724,7 +1695,7 @@ public class ResourceServiceImpl extends CrudServiceImpl selectTotalByDept() { HashMap resultMap = new HashMap<>(); Long deptId = SecurityUser.getUser().getDeptId(); List deptList = null; @@ -1855,17 +1826,17 @@ public class ResourceServiceImpl extends CrudServiceImpl() {{ - Map map = (Map) selectTotal(); - List> list = (List>) map.get("total"); - list.forEach(index -> { - if ("基础设施".equals(index.get("type").toString())) { - put("视频资源", Integer.parseInt(index.get("count").toString())); - } - }); - put("感知资源", 0); - put("云资源", 0); - }}; + HashMap resultMap = new HashMap<>(); + Map map = (Map) selectTotal(); + List> list = (List>) map.get("total"); + list.forEach(index -> { + if ("基础设施".equals(index.get("type").toString())) { + resultMap.put("视频资源", Integer.parseInt(index.get("count").toString())); + } + }); + resultMap.put("感知资源", 0); + resultMap.put("云资源", 0); + return resultMap; } private List getSourceIdsByProcess(List list) { @@ -1906,34 +1877,29 @@ public class ResourceServiceImpl extends CrudServiceImpl result = new ArrayList<>(); List> dtoMaps = baseDao.selectDevelopDocResource(); Map>> resourceTypeMap = dtoMaps.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); - resourceTypeMap.entrySet().stream().forEach(temp -> { - if (!"组件服务".equals(temp.getKey())) { - Map map = new HashMap(); - map.put("title", temp.getKey()); - map.put("children", temp.getValue()); + resourceTypeMap.forEach((key, value) -> { + if (!"组件服务".equals(key)) { + Map map = new HashMap<>(); + map.put("title", key); + map.put("children", value); result.add(map); } }); if (resourceTypeMap.get("组件服务") != null) { - Map componentMap = new HashMap(); + Map componentMap = new HashMap<>(); componentMap.put("title", "组件服务"); Map map = new ConcurrentHashMap<>(); - List tasks = resourceTypeMap.get("组件服务").stream().map(it -> { - CompletableFuture task = CompletableFuture.runAsync(() -> { - selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream().filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> { + CompletableFuture.allOf(resourceTypeMap.get("组件服务").stream().map(it -> CompletableFuture.runAsync(() -> selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream() + .filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> { if (map.get(attr.getAttrValue()) != null) { map.get(attr.getAttrValue()).add(it); } else { - map.put(attr.getAttrValue(), (List) Collections.synchronizedList(new ArrayList() {{ + map.put(attr.getAttrValue(), Collections.synchronizedList(new ArrayList() {{ add(it); }})); } - }); - }, executor); - return task; - }).collect(Collectors.toList()); - CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); - componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{ + }), executor)).toArray(CompletableFuture[]::new)).join(); + componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{ put("title", it.getKey()); put("children", it.getValue()); }}).collect(Collectors.toList())); diff --git a/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java b/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java index 014455cc..705e0264 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java +++ b/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java @@ -47,6 +47,7 @@ public class ShiroSessionManager extends DefaultWebSessionManager { } } + /*@Override protected void onStart(Session session, SessionContext context) { log.info("执行onStart"); diff --git a/renren-admin/src/main/resources/domain/tsingtao-xha.properties b/renren-admin/src/main/resources/domain/tsingtao-xha.properties index 5ddad40a..f6b7177e 100644 --- a/renren-admin/src/main/resources/domain/tsingtao-xha.properties +++ b/renren-admin/src/main/resources/domain/tsingtao-xha.properties @@ -1,7 +1,7 @@ tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls tsingtao-xha.cloudcam=http://10.10.30.9:8001/data_service/getCamera/getCameraCount -tsingtao-xha.localcam=http://10.134.135.9:8001/data_service/getCamera/getCameraCount +tsingtao-xha.localcam=http://10.10.30.57:9537/data_service/getCamera/getCameraCount tsingtao-xha.resourcecount=http://10.10.30.24:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=&type=&orderField=requestNum&orderType=desc&pageNum=1&pageSize=10&serviceType=data&rq=1655106309671.43 tsingtao-xha.resourceapplyinfo=http://10.10.30.24:30058/share-portal/platform/index/abilityMarket/count tsingtao-xha.sjzy=http://10.10.30.24:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=%s&type=&orderField=%s&orderType=%s&pageNum=%s&pageSize=%s&serviceType=data&rq=1655106309671.43 \ No newline at end of file