diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java index cfb84061..3dc11df1 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java @@ -322,7 +322,21 @@ public class CensusControllerV2 { List> result = new CopyOnWriteArrayList<>(); CompletableFuture allAmount = null; switch (Constant.ProjectPlace.getByFlag(projectPlace)) { - case TSINGTAO: // 青岛市局 + case TSINGTAO: { // 青岛市局 + allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 + Map map = (Map) resourceService.selectTotal(); + List> dbAmount = (List>) map.get("total"); + return dbAmount.stream().mapToLong(index -> Long.parseLong(index.get("count").toString())).sum(); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + }); + }); + } + break; case BAOTOU: { // 包头 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class); 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 824f2418..9d36f4b1 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 @@ -316,13 +316,14 @@ public class ResourceServiceImpl extends CrudServiceImpl { + ResourceDTO index = (ResourceDTO) x; + return index.getTotal() == null ? 0L : index.getTotal(); + }).reversed()).collect(Collectors.toList())); } else { resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null); } - resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> { - ResourceDTO index = (ResourceDTO) x; - return index.getTotal() == null ? 0L : index.getTotal(); - }).reversed()).collect(Collectors.toList())); + resultPage.setRecords(resourceDTOS); resultPage.setTotal(resourceDao.selectDTOPageCount(resourceDTO)); } else { List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType); @@ -557,7 +558,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> assemblerCarDetail(Map params) { List> result = new ArrayList<>(); Object[] ps = {params.get("resourceType"), params.get("id"), 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 sys_dept c ON b.dept_id = c.id INNER JOIN tb_data_resource d on a.resource_id = d.id WHERE a.del_flag = 0 " + - "AND d.type = ? AND (c.id = ? or INSTR(c.pids,?)) 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 sys_dept c ON b.dept_id = c.id INNER JOIN tb_data_resource d ON a.resource_id = d.id WHERE a.del_flag = 0 " + + "AND d.type = ? AND (c.id = ? OR INSTR(c.pids,?)) ORDER BY a.create_date DESC LIMIT ?,?", ps); return result; } @@ -1512,8 +1513,8 @@ public class ResourceServiceImpl extends CrudServiceImpl deptList=null; - if(deptId != null){ + List deptList = null; + if (deptId != null) { deptList = deptService.getSubDeptIdList(deptId); } boolean isAsc = false; @@ -1523,7 +1524,7 @@ public class ResourceServiceImpl extends CrudServiceImpl page = new Page<>(curPage, limit); QueryWrapper queryWrapper = new QueryWrapper<>(); - if(deptList != null){ + if (deptList != null) { queryWrapper.in("dept_id", deptList); } queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).orderBy(true, isAsc, orderColumn); @@ -1534,8 +1535,8 @@ public class ResourceServiceImpl extends CrudServiceImpl resultMap = new HashMap<>(); Long deptId = SecurityUser.getUser().getDeptId(); - List deptList=null; - if(deptId != null){ + List deptList = null; + if (deptId != null) { deptList = deptService.getSubDeptIdList(deptId); } resultMap.put("total", resourceDao.selectCountByDepts(deptList)); @@ -1569,9 +1570,9 @@ public class ResourceServiceImpl extends CrudServiceImpl page = new Page<>(curPage, limit); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("id", resourceIds).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).orderBy(true, isAsc, orderColumn); - List dtoList=ConvertUtils.sourceToTarget(resourceDao.selectPage(page, queryWrapper).getRecords(), ResourceDTO.class); - dtoList.forEach(temp->{ - Map p=new HashMap(); + List dtoList = ConvertUtils.sourceToTarget(resourceDao.selectPage(page, queryWrapper).getRecords(), ResourceDTO.class); + dtoList.forEach(temp -> { + Map p = new HashMap(); p.put("resource_id", temp.getId()); temp.setApplyCount(String.valueOf(tAbilityApplicationService.list(p).size())); }); @@ -1604,12 +1605,12 @@ public class ResourceServiceImpl extends CrudServiceImpl deptList=null; - if(deptId != null){ - deptList=deptService.getSubDeptIdList(deptId); + Long deptId = SecurityUser.getUser().getDeptId(); + List deptList = null; + if (deptId != null) { + deptList = deptService.getSubDeptIdList(deptId); } - List result=resourceDao.selectDeptResourceByApplyNum(deptList); + List result = resourceDao.selectDeptResourceByApplyNum(deptList); Page page = new Page(curPage, limit); int j = Math.min(curPage * limit, result.size()); if (result.isEmpty()) { @@ -1628,12 +1629,12 @@ public class ResourceServiceImpl extends CrudServiceImpl deptList=null; - if(deptId != null){ + List deptList = null; + if (deptId != null) { deptList = deptService.getSubDeptIdList(deptId); } params.put("deptIds", deptList); @@ -1677,7 +1678,7 @@ public class ResourceServiceImpl extends CrudServiceImpl() {{ Map map = (Map) selectTotal(); List> list = (List>) map.get("total"); - list.forEach(index ->{ + list.forEach(index -> { if ("基础设施".equals(index.get("type").toString())) { put("视频资源", Integer.parseInt(index.get("count").toString())); } diff --git a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml index 1d96417b..27707402 100644 --- a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml @@ -90,12 +90,38 @@ res.del_flag AS "delFlag", car.note1, car.create_date AS "time", - res.del_flag AS "delFlag" + tda.attr_value AS "componentType" + FROM + tb_resource_car car, + tb_data_resource res, + tb_data_attr tda + WHERE 1 = 1 + AND car.resource_id = res.id + AND res.id = tda.data_resource_id + AND car.resource_id != 8888888880000000001 + AND tda.attr_type = '组件类型' + AND tda.del_flag = 0 + AND car.user_id = #{userId} + AND res.dept_id = #{deptId} + AND car.del_flag = 0 + UNION + SELECT + car.id AS "id", + res.id AS "resourceId", + '申请摄像头列表' AS "resourceName", + res.description, + res.type, + 0 AS "delFlag", + car.note1, + car.create_date AS "time", + "" AS "componentType" FROM tb_resource_car car, tb_data_resource res - WHERE 1 = 1 + WHERE + 1 = 1 AND car.resource_id = res.id + AND car.resource_id = 8888888880000000001 AND car.user_id = #{userId} AND res.dept_id = #{deptId} AND car.del_flag = 0