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; import io.swagger.annotations.ApiResponses; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; 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; /** * 数据总览 */ @Api(value = "/dataScreening", tags = "check", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ApiResponses(@ApiResponse(code = 404, message = "dataScreening not found")) @Slf4j @RestController @RequestMapping(value = Constants.BASE_API_PATH + "/dataScreening", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public class DataScreeningController extends BaseController { @Autowired private CatalogueService catalogueService; @Autowired private ViewService viewService; @ApiOperation(value = "get dataScreening") @GetMapping public ResponseEntity dataScreening( HttpServletRequest request) { Map result = new HashMap(); List viewList = viewService.getAllViews(); if (null == viewList) { viewList = new ArrayList(); } // 数据资源数量 int dataSource = 0; result.put("dataSource", viewList.size()); // 来源部门数量 int originDept = 0; List catalogueOrigins = catalogueService.getCatalogueOriginDept(); result.put("originDept", catalogueOrigins.size()); // 来源系统数量 int originSystem = 0; List catalogueOriginList = catalogueService.getCatalogueOriginSystem(); result.put("originSystem", catalogueOriginList.size()); // 近一个月目录增长数量 int countCatalogue = 0; List catalogueList = catalogueService.getCatalogueMonth(); result.put("countCatalogue", catalogueList.size()); // 行业分类饼图 Map> mapIndustry = viewList.stream().collect(Collectors.groupingBy(ViewExt::getIndustry)); result.put("industryData", mapIndustry); // 数据资源来源部门柱状图 Map> mapOriginDept = viewList.stream().collect(Collectors.groupingBy(ViewExt::getOriginDept)); result.put("originDeptData", mapOriginDept); return ResponseEntity.status(HttpStatus.OK).body(result); } }