diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index 19c429c7..2e45a1c6 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -61,15 +61,7 @@ public class CensusController { List> dbAmount = resourceService.getAmountGroupByType(); List temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList()); Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型 - if (index.equals("知识库")) { - Map nullMap = new HashMap() { - { - put("amount", 14); - put("type", "知识库"); - } - }; - dbAmount.add(nullMap); - } else if (index.equals("数据资源")) { + if (index.equals("数据资源")) { Map nullMap = new HashMap() { { put("amount", 10413); 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 fb75b0c2..6433763b 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 @@ -33,7 +33,7 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/census/center/v2") public class CensusControllerV2 { - private static Logger logger = LoggerFactory.getLogger(CensusControllerV2.class); + private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class); @Autowired private ResourceService resourceService; @@ -289,4 +289,11 @@ public class CensusControllerV2 { return new Result().ok(result); } + @GetMapping("/componentServiceRank") + @ApiOperation("组件服务排名") + @LogOperation("组件服务排名") + public Result componentServiceRank(String type) { + return new Result().ok(resourceService.componentServiceRank(type)); + } + } 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 1f39b7df..91324236 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 @@ -289,7 +289,6 @@ public class ResourceController { HashMap map = JSONObject.parseObject(json, HashMap.class); return new Result().ok(map); } catch (Exception e) { - e.printStackTrace(); return new Result().ok(new HashMap() {{ put("sxmlcount", 0); put("yfbfwcount", 0); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java index f9309b18..1993e481 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java @@ -106,4 +106,7 @@ public interface ResourceDao extends BaseDao { List selectAppAreaCountList(); + List selectTopFiveComponentServiceApplications(); + + List selectTopFiveComponentServiceScore(); } \ No newline at end of file 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 6a38dba1..45888fe0 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 @@ -79,4 +79,6 @@ public interface ResourceService extends CrudService implements ResourceService { + private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class); + @Value("${zsk.appid}") private String appId; @@ -250,7 +252,7 @@ public class ResourceServiceImpl extends CrudServiceImpl resultMap = new HashMap<>(); - resultMap.put("total", resourceDao.selectTypeCount()); + resultMap.put("total", resourceDao.selectTypeCount(null)); return resultMap; } @@ -291,7 +293,6 @@ public class ResourceServiceImpl extends CrudServiceImpl !"区级".equals(index.getKey())).forEach(item -> { HashMap map = new HashMap<>(); map.put("type", item.getKey()); - map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"))); + 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()); - resultList.add(map); + if (integer != 0) { + resultList.add(map); + } }); Optional>> areaList = Optional.ofNullable(listMap.get("区级")); Optional>>> areaTypeList = Optional.ofNullable(areaList.orElse(new ArrayList<>()).stream() .collect(Collectors.groupingBy(m -> m.get("districtName").toString()))); HashMap areaMap = new HashMap<>(); areaMap.put("type", "区级"); - areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type"))); + Integer integer = resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")); + areaMap.put("total", integer); ArrayList areaListTemp = new ArrayList<>(); areaTypeList.orElse(new HashMap<>()).forEach((key, value) -> { HashMap map = new HashMap<>(); @@ -393,7 +398,9 @@ public class ResourceServiceImpl extends CrudServiceImpl(); + } + } } \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index d5ed07ac..5db605b9 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1,4 +1,4 @@ - + @@ -179,6 +179,9 @@ FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 + + AND type = #{type} + GROUP BY type ORDER BY type @@ -249,7 +252,7 @@ sd.NAME AS "deptName", IFNULL( trc2.isCollect, 'false' ) AS "isCollect", IF - ( taa2.approve_status < 1, '未申请', "已申请" ) AS "applyState" + ( taa2.approve_status < 1, '未申请', '已申请' ) AS "applyState" FROM tb_data_resource tdr LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 @@ -890,4 +893,46 @@ type + + + + \ No newline at end of file