企业信息统计 根据企业类型统计企业数据接口返回格式调整

This commit is contained in:
lc 2024-06-21 17:18:38 +08:00
parent 895f2851ba
commit 11a80dd985
3 changed files with 24 additions and 6 deletions

View File

@ -103,8 +103,8 @@ public class EnterpriseInformationController {
} }
@GetMapping("/statisticByEnterpriseType") @GetMapping("/statisticByEnterpriseType")
@Operation(summary = "根据企业类型统计企业数据") @Operation(summary = "根据企业类型统计企业数据")
public CommonResult<Map<Integer,Long>> statisticByEnterpriseType(){ public CommonResult<List<StatisticsResultData>> statisticByEnterpriseType(){
Map<Integer, Long> integerLongMap = enterpriseInformationService.statisticByEnterpriseType(); List<StatisticsResultData> integerLongMap = enterpriseInformationService.statisticByEnterpriseType();
return success(integerLongMap); return success(integerLongMap);
} }
@GetMapping("/selectEnterpriseByYear") @GetMapping("/selectEnterpriseByYear")

View File

@ -83,7 +83,7 @@ public interface EnterpriseInformationService {
* 根据企业类型统计企业数据 * 根据企业类型统计企业数据
* @return * @return
*/ */
Map<Integer,Long> statisticByEnterpriseType(); List<StatisticsResultData> statisticByEnterpriseType();
/** /**
* 查询平台企业年度注册数 * 查询平台企业年度注册数

View File

@ -243,10 +243,28 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe
* @return * @return
*/ */
@Override @Override
public Map<Integer, Long> statisticByEnterpriseType() { public List<StatisticsResultData> statisticByEnterpriseType() {
List<EnterpriseInformationDO> enterpriseInformationDOS = enterpriseInformationMapper.selectList(); List<EnterpriseInformationDO> enterpriseInformationDOS = enterpriseInformationMapper.selectList();
Map<Integer, Long> enterpriseTypeCounts = enterpriseInformationDOS.stream().collect(Collectors.groupingBy(EnterpriseInformationDO::getEnterpriseType, Collectors.counting())); Map<Integer, Long> enterpriseTypeCounts = enterpriseInformationDOS.stream()
return enterpriseTypeCounts; .collect(Collectors.groupingBy(EnterpriseInformationDO::getEnterpriseType, Collectors.counting()));
List<StatisticsResultData> list = new ArrayList<>();
StatisticsResultData greatEnterprise = new StatisticsResultData();
greatEnterprise.setName("analysis.greatEnterprise");
greatEnterprise.setValue(enterpriseTypeCounts.get(3));//大型企业
StatisticsResultData centreEnterprise = new StatisticsResultData();
centreEnterprise.setName("analysis.centreEnterprise");
centreEnterprise.setValue(enterpriseTypeCounts.get(2));//中型企业
StatisticsResultData smallEnterprise = new StatisticsResultData();
smallEnterprise.setName("analysis.smallEnterprise");
smallEnterprise.setValue(enterpriseTypeCounts.get(1));//小型企业
list.add(greatEnterprise);
list.add(centreEnterprise);
list.add(smallEnterprise);
return list;
} }
/** /**