浏览代码

数据总览

vincent 3 年之前
父节点
当前提交
0e00ad3985

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

@@ -2,7 +2,13 @@ package edp.davinci.controller;
 
 import edp.davinci.common.controller.BaseController;
 import edp.davinci.core.common.Constants;
+import edp.davinci.dto.catalogue.CatalogueOrigin;
+import edp.davinci.dto.viewDto.ViewBaseInfo;
+import edp.davinci.dto.viewDto.ViewExt;
+import edp.davinci.model.Catalogue;
+import edp.davinci.model.View;
 import edp.davinci.service.CatalogueService;
+import edp.davinci.service.ViewService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
@@ -17,8 +23,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 数据总览
@@ -33,6 +42,9 @@ public class DataScreeningController extends BaseController
     @Autowired
     private CatalogueService catalogueService;
 
+    @Autowired
+    private ViewService viewService;
+
     @ApiOperation(value = "get dataScreening")
     @GetMapping
     public ResponseEntity dataScreening(
@@ -40,20 +52,39 @@ public class DataScreeningController extends BaseController
     {
 
         Map<String, Object> result = new HashMap<String, Object>();
+        List<ViewExt> viewList = viewService.getAllViews();
+        if (null == viewList)
+        {
+            viewList = new ArrayList<ViewExt>();
+        }
+
         // 数据资源数量
         int dataSource = 0;
-        result.put("dataSource", dataSource);
+        result.put("dataSource", viewList.size());
+
         // 来源部门数量
         int originDept = 0;
-        result.put("originDept", originDept);
+        List<CatalogueOrigin> catalogueOrigins = catalogueService.getCatalogueOriginDept();
+        result.put("originDept", catalogueOrigins.size());
+
         // 来源系统数量
         int originSystem = 0;
-        result.put("originSystem", originSystem);
+        List<CatalogueOrigin> catalogueOriginList = catalogueService.getCatalogueOriginSystem();
+        result.put("originSystem", catalogueOriginList.size());
+
         // 近一个月目录增长数量
         int countCatalogue = 0;
-        result.put("countCatalogue", countCatalogue);
+        List<Catalogue> catalogueList = catalogueService.getCatalogueMonth();
+        result.put("countCatalogue", catalogueList.size());
+
         // 行业分类饼图
+        Map<String, List<ViewExt>> mapIndustry = viewList.stream().collect(Collectors.groupingBy(ViewExt::getIndustry));
+        result.put("industrys", mapIndustry);
+
         // 数据资源来源部门柱状图
+        Map<String, List<ViewExt>> mapOriginDept = viewList.stream().collect(Collectors.groupingBy(ViewExt::getOriginDept));
+        result.put("originDept", mapOriginDept);
+
         return ResponseEntity.status(HttpStatus.OK).body(result);
     }
 

+ 21 - 13
server/src/main/java/edp/davinci/dao/CatalogueMapper.java

@@ -19,6 +19,7 @@
 
 package edp.davinci.dao;
 
+import edp.davinci.dto.catalogue.CatalogueOrigin;
 import edp.davinci.model.Catalogue;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
@@ -37,18 +38,13 @@ public interface CatalogueMapper
     @Select({"select id from `catalogue` where project_id = #{projectId} and `name` = #{name}"})
     Long getByNameWithProjectId(@Param("name") String name, @Param("projectId") Long projectId);
 
-//    ViewWithProjectAndSource getViewWithProjectAndSourceById(@Param("id") Long id);
-
-//    ViewWithProjectAndSource getViewWithProjectAndSourceByWidgetId(@Param("widgetId") Long widgetId);
-
     @Delete({"delete from `catalogue` where id = #{id}"})
     int deleteById(Long id);
 
     @Select({"select * from `catalogue` where id = #{id}"})
     Catalogue getById(Long id);
 
-//    @Select({"select id, name, model, variable from `view` where id = #{id}"})
-//    SimpleView getSimpleViewById(Long id);
+
 
     @Update({
             "update `catalogue`",
@@ -76,13 +72,25 @@ public interface CatalogueMapper
 //    })
 //    ViewWithSourceBaseInfo getViewWithSourceBaseInfo(@Param("id") Long id);
 
-//    @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.project_id = #{projectId}"
-//    })
-//    List<ViewBaseInfo> getViewBaseInfoByProject(@Param("projectId") Long projectId);
+    @Select({
+            "select origin_system from catalogue GROUP BY origin_system"
+    })
+    List<CatalogueOrigin> getCatalogueOriginSystem();
+
+    @Select({
+            "select origin_dept from catalogue GROUP BY origin_dept"
+    })
+    List<CatalogueOrigin> getCatalogueOriginDept();
+
+    @Select({
+            "select industry from catalogue GROUP BY industry"
+    })
+    List<CatalogueOrigin> getCatalogueIndustry();
+
+    @Select({
+            "SELECT * FROM catalogue where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= create_time"
+    })
+    List<Catalogue> getCatalogueMonth();
 
     int insertBatch(@Param("list") List<Catalogue> catalogueList);
 

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

@@ -38,6 +38,9 @@ public interface ViewMapper {
     @Select({"select id from `view` where project_id = #{projectId} and `name` = #{name}"})
     Long getByNameWithProjectId(@Param("name") String name, @Param("projectId") Long projectId);
 
+    @Select({"SELECT v.*,c.industry,c.origin_dept FROM `view` v LEFT JOIN catalogue c ON c.id = v.parent_id"})
+    List<ViewExt> getViewAll();
+
     ViewWithProjectAndSource getViewWithProjectAndSourceById(@Param("id") Long id);
 
     ViewWithProjectAndSource getViewWithProjectAndSourceByWidgetId(@Param("widgetId") Long widgetId);
@@ -86,6 +89,14 @@ public interface ViewMapper {
     })
     List<ViewBaseInfo> getViewBaseInfoByProject(@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> getViewBaseInfoByParentId(@Param("parentId") Long parentId);
+
     int insertBatch(@Param("list") List<View> sourceList);
 
     @Delete({"delete from `view` where project_id = #{projectId}"})

+ 15 - 0
server/src/main/java/edp/davinci/dto/catalogue/CatalogueOrigin.java

@@ -0,0 +1,15 @@
+package edp.davinci.dto.catalogue;
+
+import lombok.Data;
+
+@Data
+public class CatalogueOrigin
+{
+    private String originDept;
+
+    private String originSystem;
+
+    private String industry;
+
+    private int count;
+}

+ 13 - 0
server/src/main/java/edp/davinci/dto/viewDto/ViewExt.java

@@ -0,0 +1,13 @@
+package edp.davinci.dto.viewDto;
+
+import edp.davinci.model.View;
+import lombok.Data;
+
+@Data
+public class ViewExt extends View
+{
+    private String industry;
+
+    private String originDept;
+
+}

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

@@ -3,6 +3,7 @@ package edp.davinci.service;
 import edp.core.exception.NotFoundException;
 import edp.core.exception.ServerException;
 import edp.core.exception.UnAuthorizedException;
+import edp.davinci.dto.catalogue.CatalogueOrigin;
 import edp.davinci.model.Catalogue;
 import edp.davinci.model.User;
 
@@ -17,4 +18,14 @@ public interface CatalogueService
     boolean updateCatalogue(Catalogue catalogue, User user) throws NotFoundException, UnAuthorizedException, ServerException;
 
     boolean deleteCatalogue(Long id, User user) throws NotFoundException, UnAuthorizedException, ServerException;
+
+    Catalogue getById(Long id) throws NotFoundException, UnAuthorizedException, ServerException;
+
+    List<CatalogueOrigin> getCatalogueOriginSystem() throws NotFoundException, UnAuthorizedException, ServerException;
+
+    List<CatalogueOrigin> getCatalogueOriginDept() throws NotFoundException, UnAuthorizedException, ServerException;
+
+    List<CatalogueOrigin> getCatalogueIndustry() throws NotFoundException, UnAuthorizedException, ServerException;
+
+    List<Catalogue> getCatalogueMonth() throws NotFoundException, UnAuthorizedException, ServerException;
 }

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

@@ -29,6 +29,7 @@ import edp.davinci.core.service.CheckEntityService;
 import edp.davinci.dto.viewDto.*;
 import edp.davinci.model.SqlVariable;
 import edp.davinci.model.User;
+import edp.davinci.model.View;
 import edp.davinci.service.excel.SQLContext;
 
 import java.sql.SQLException;
@@ -38,6 +39,8 @@ import java.util.Set;
 
 public interface ViewService extends CheckEntityService {
 
+    List<ViewExt> getAllViews() throws NotFoundException, UnAuthorizedException, ServerException;
+
     List<ViewBaseInfo> getViews(Long projectId, User user) throws NotFoundException, UnAuthorizedException, ServerException;
 
     ViewWithSourceBaseInfo createView(ViewCreate viewCreate, User user) throws NotFoundException, UnAuthorizedException, ServerException;
@@ -58,6 +61,8 @@ public interface ViewService extends CheckEntityService {
 
     ViewWithSourceBaseInfo getView(Long id, User user) throws NotFoundException, UnAuthorizedException, ServerException;
 
+    List<ViewBaseInfo> getViewBaseInfoByParentId(Long projectId) throws NotFoundException, UnAuthorizedException, ServerException;
+
     SQLContext getSQLContext(boolean isMaintainer, ViewWithSource viewWithSource, ViewExecuteParam executeParam, User user);
 
     void packageParams(boolean isProjectMaintainer, Long viewId, SqlEntity sqlEntity, List<SqlVariable> variables, List<Param> paramList, Set<String> excludeColumns, User user);

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

@@ -4,6 +4,7 @@ import edp.core.exception.NotFoundException;
 import edp.core.exception.ServerException;
 import edp.core.exception.UnAuthorizedException;
 import edp.davinci.dao.CatalogueMapper;
+import edp.davinci.dto.catalogue.CatalogueOrigin;
 import edp.davinci.model.Catalogue;
 import edp.davinci.model.User;
 import edp.davinci.service.CatalogueService;
@@ -56,4 +57,34 @@ public class CatalogueServiceImpl implements CatalogueService
         }
         return false;
     }
+
+    @Override
+    public Catalogue getById(Long id) throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return catalogueMapper.getById(id);
+    }
+
+    @Override
+    public List<CatalogueOrigin> getCatalogueOriginSystem() throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return catalogueMapper.getCatalogueOriginSystem();
+    }
+
+    @Override
+    public List<CatalogueOrigin> getCatalogueOriginDept() throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return catalogueMapper.getCatalogueOriginDept();
+    }
+
+    @Override
+    public List<CatalogueOrigin> getCatalogueIndustry() throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return catalogueMapper.getCatalogueIndustry();
+    }
+
+    @Override
+    public List<Catalogue> getCatalogueMonth() throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return catalogueMapper.getCatalogueMonth();
+    }
 }

+ 12 - 0
server/src/main/java/edp/davinci/service/impl/ViewServiceImpl.java

@@ -114,6 +114,12 @@ ViewServiceImpl extends BaseEntityService implements ViewService {
         return null != viewId && viewId.longValue() > 0L;
     }
 
+    @Override
+    public List<ViewExt> getAllViews() throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return viewMapper.getViewAll();
+    }
+
     /**
      * 获取View列表
      *
@@ -168,6 +174,12 @@ ViewServiceImpl extends BaseEntityService implements ViewService {
     }
 
     @Override
+    public List<ViewBaseInfo> getViewBaseInfoByParentId(Long parentId) throws NotFoundException, UnAuthorizedException, ServerException
+    {
+        return viewMapper.getViewBaseInfoByParentId(parentId);
+    }
+
+    @Override
     public SQLContext getSQLContext(boolean isMaintainer, ViewWithSource viewWithSource, ViewExecuteParam executeParam, User user) {
 
         if (null == executeParam || (CollectionUtils.isEmpty(executeParam.getGroups()) && CollectionUtils.isEmpty(executeParam.getAggregators()))) {