浏览代码

数据概览

vincent 3 年之前
父节点
当前提交
ca1f0c133e

+ 38 - 4
server/src/main/java/edp/davinci/controller/DataScreeningController.java

@@ -79,12 +79,46 @@ public class DataScreeningController extends BaseController
         result.put("countCatalogue", countCatalogue);
 
         // 行业分类饼图
-        Map<String, List<ViewExt>> mapIndustry = viewList.stream().collect(Collectors.groupingBy(ViewExt::getIndustry));
-        result.put("industryData", mapIndustry);
+        // 1. 先按照行业获取数据资源目录
+        // 2. 根据目录获取资源数量
+        List<Catalogue> catalogues = catalogueService.getCatalogueList();
+        Map<String, List<Catalogue>> mapIndustry = catalogues.stream().filter(map->map.getIndustry() != null).collect(Collectors.groupingBy(Catalogue::getIndustry,Collectors.toList()));
+        //
+        List<Map<String,Object>> industryData = new ArrayList<>();
+        mapIndustry.forEach((k, v) -> {
+            Map<String,Object> data = new HashMap<>();
+            String deptName = k;
+            List<Catalogue> listCatalogue = v;
+            int count = 0;
+            for(Catalogue c: listCatalogue){
+                List<ViewBaseInfo> views = viewService.getViewBaseInfoByOnlyParentId(c.getId());
+                count += views.size();
+            }
+            data.put("name",k);
+            data.put("value",count);
+            industryData.add(data);
+        });
+        result.put("industryData", industryData);
 
         // 数据资源来源部门柱状图
-        Map<String, List<ViewExt>> mapOriginDept = viewList.stream().collect(Collectors.groupingBy(ViewExt::getOriginDept));
-        result.put("originDeptData", mapOriginDept);
+        // 1. 按照部门获取数据资源目录
+        // 2. 根据数据资源目录获取数据资源
+        Map<String, List<Catalogue>> mapOriginDept = catalogues.stream().filter(map->map.getOriginDept() != null).collect(Collectors.groupingBy(Catalogue::getOriginDept,Collectors.toList()));
+        List<Map<String,Object>> originDeptData = new ArrayList<>();
+        mapOriginDept.forEach((k, v) -> {
+            Map<String,Object> data = new HashMap<>();
+            String deptName = k;
+            List<Catalogue> listCatalogue = v;
+            int count = 0;
+            for(Catalogue c: listCatalogue){
+                List<ViewBaseInfo> views = viewService.getViewBaseInfoByOnlyParentId(c.getId());
+                count += views.size();
+            }
+            data.put("name",k);
+            data.put("value",count);
+            originDeptData.add(data);
+        });
+        result.put("originDeptData", originDeptData);
 
         return ResponseEntity.status(HttpStatus.OK).body(result);
     }

+ 3 - 0
server/src/main/java/edp/davinci/dao/CatalogueMapper.java

@@ -64,6 +64,9 @@ public interface CatalogueMapper
     @Select({"select * from `catalogue` where project_id = #{projectId}"})
     List<Catalogue> getByProjectId(@Param("projectId") Long projectId);
 
+    @Select({"select * from `catalogue`"})
+    List<Catalogue> getCatalogues();
+
 //    @Select({
 //            "select v.*,",
 //            "s.id as 'source.id', s.`name` as 'source.name' from `view` v ",

+ 8 - 0
server/src/main/java/edp/davinci/dao/ViewMapper.java

@@ -97,6 +97,14 @@ public interface ViewMapper {
     })
     List<ViewBaseInfo> getViewBaseInfoByParentId(@Param("parentId") Long parentId,@Param("projectId") Long projectId);
 
+    @Select({
+            "select v.id, v.`name`, v.`description`, s.name as 'sourceName'",
+            "from `view` v ",
+            "left join source s on s.id = v.source_id ",
+            "where v.parent_id = #{parentId}"
+    })
+    List<ViewBaseInfo> getViewBaseInfoByOnlyParentId(@Param("parentId") Long parentId);
+
     int insertBatch(@Param("list") List<View> sourceList);
 
     @Delete({"delete from `view` where project_id = #{projectId}"})

+ 2 - 0
server/src/main/java/edp/davinci/service/CatalogueService.java

@@ -13,6 +13,8 @@ public interface CatalogueService
 {
     List<Catalogue> getCatalogues(Long projectId, User user) throws NotFoundException, UnAuthorizedException, ServerException;
 
+    List<Catalogue> getCatalogueList() throws NotFoundException, UnAuthorizedException, ServerException;
+
     Catalogue createCatalogue(Catalogue catalogue, User user) throws NotFoundException, UnAuthorizedException, ServerException;
 
     boolean updateCatalogue(Catalogue catalogue, User user) throws NotFoundException, UnAuthorizedException, ServerException;

+ 1 - 0
server/src/main/java/edp/davinci/service/ViewService.java

@@ -62,6 +62,7 @@ public interface ViewService extends CheckEntityService {
     ViewWithSourceBaseInfo getView(Long id, User user) throws NotFoundException, UnAuthorizedException, ServerException;
 
     List<ViewBaseInfo> getViewBaseInfoByParentId(Long projectId, Long parentId, User user) throws NotFoundException, UnAuthorizedException, ServerException;
+    List<ViewBaseInfo> getViewBaseInfoByOnlyParentId(Long parentId) throws NotFoundException, UnAuthorizedException, ServerException;
 
     SQLContext getSQLContext(boolean isMaintainer, ViewWithSource viewWithSource, ViewExecuteParam executeParam, User user);
 

+ 6 - 0
server/src/main/java/edp/davinci/service/impl/CatalogueServiceImpl.java

@@ -28,6 +28,12 @@ public class CatalogueServiceImpl implements CatalogueService
     }
 
     @Override
+    public List<Catalogue> getCatalogueList() throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return catalogueMapper.getCatalogues();
+    }
+
+    @Override
     public Catalogue createCatalogue(Catalogue catalogue, User user) throws NotFoundException, UnAuthorizedException, ServerException
     {
         catalogueMapper.insert(catalogue);

+ 7 - 2
server/src/main/java/edp/davinci/service/impl/ViewServiceImpl.java

@@ -70,8 +70,7 @@ import static edp.davinci.core.enums.SqlVariableTypeEnum.QUERYVAR;
 
 @Slf4j
 @Service("viewService")
-public class
-ViewServiceImpl extends BaseEntityService implements ViewService
+public class ViewServiceImpl extends BaseEntityService implements ViewService
 {
 
     private static final Logger optLogger = LoggerFactory.getLogger(LogNameEnum.BUSINESS_OPERATION.getName());
@@ -212,6 +211,12 @@ ViewServiceImpl extends BaseEntityService implements ViewService
     }
 
     @Override
+    public List<ViewBaseInfo> getViewBaseInfoByOnlyParentId(Long parentId) throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return viewMapper.getViewBaseInfoByOnlyParentId(parentId);
+    }
+
+    @Override
     public SQLContext getSQLContext(boolean isMaintainer, ViewWithSource viewWithSource, ViewExecuteParam executeParam, User user)
     {