diff --git a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/controller/admin/enterpriseinformation/EnterpriseInformationController.java b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/controller/admin/enterpriseinformation/EnterpriseInformationController.java index 3670b81..6b8cd17 100644 --- a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/controller/admin/enterpriseinformation/EnterpriseInformationController.java +++ b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/controller/admin/enterpriseinformation/EnterpriseInformationController.java @@ -106,4 +106,24 @@ public class EnterpriseInformationController { Map integerLongMap = enterpriseInformationService.statisticByEnterpriseType(); return success(integerLongMap); } + @GetMapping("/selectEnterpriseByYear") + @Operation(summary = "查询平台企业年度注册数") + public CommonResult> selectEnterpriseByYear(){ + Map integerLongMap = enterpriseInformationService.selectEnterpriseByYear(); + return success(integerLongMap); + } + + @GetMapping("/selectEnterpriseByQuarter") + @Operation(summary = "查询平台企业季度注册数") + public CommonResult> selectEnterpriseByQuarter(){ + Map stringLongMap = enterpriseInformationService.selectEnterpriseByQuarter(); + return success(stringLongMap); + } + + @GetMapping("/selectEnterpriseByMonth") + @Operation(summary = "查询平台企业月度注册数") + public CommonResult> selectEnterpriseByMonth(){ + Map stringLongMap = enterpriseInformationService.selectEnterpriseByMonth(); + return success(stringLongMap); + } } diff --git a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationService.java b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationService.java index 235d2e6..b4004e5 100644 --- a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationService.java +++ b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationService.java @@ -82,4 +82,22 @@ public interface EnterpriseInformationService { * @return */ Map statisticByEnterpriseType(); + + /** + * 查询平台企业年度注册数 + * @return + */ + Map selectEnterpriseByYear(); + + /** + * 查询平台企业季度注册数 + * @return + */ + Map selectEnterpriseByQuarter(); + + /** + * 查询平台企业月度注册数 + * @return + */ + Map selectEnterpriseByMonth(); } diff --git a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationServiceImpl.java b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationServiceImpl.java index 53447ea..b648c00 100644 --- a/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationServiceImpl.java +++ b/yudao-module-fta/yudao-module-fta-biz/src/main/java/cn/iocoder/yudao/module/fta/service/enterpriseinformation/EnterpriseInformationServiceImpl.java @@ -241,6 +241,73 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe return enterpriseTypeCounts; } + /** + * 查询平台企业年度注册数 + * @return + */ + @Override + public Map selectEnterpriseByYear() { + List enterpriseInformationDOS = enterpriseInformationMapper.selectList(); + + // 按年分组并计算企业数量 + Map collect = enterpriseInformationDOS.stream() + .collect(Collectors.groupingBy(enterprise -> enterprise.getCreateTime().getYear(), Collectors.counting())); + + + + +//// 按月分组并计算企业数量 +// Map monthlyCounts = enterpriseInformationDOS.stream() +// .collect(Collectors.groupingBy( +// EnterpriseInformationDO::getCreateTime::toYearMonth, // 注意这里需要修改以适配Java的语法 +// Collectors.counting() +// )); +// +//// 注意:上面的toYearMonth是一个假设的方法,Java中并没有这样的方法直接在Lambda表达式中使用 +//// 你需要创建一个Function来实现这个转换 +// Function toYearMonth = LocalDate::toYearMonth; +// Map monthlyCountsCorrect = enterpriseInformationDOS.stream() +// .collect(Collectors.groupingBy( +// toYearMonth, // 使用上面定义的Function +// Collectors.counting() +// )); + + return collect; + } + + /** + * 查询平台企业季度注册数 + * @return + */ + @Override + public Map selectEnterpriseByQuarter() { + List enterpriseInformationDOS = enterpriseInformationMapper.selectList(); + // 按季度分组并计算企业数量 + Map quarterlyCounts = enterpriseInformationDOS.stream() + .collect(Collectors.groupingBy( + enterprise -> enterprise.getCreateTime().getYear() + "-" + + ((enterprise.getCreateTime().getMonthValue() - 1) / 3 + 1), // 季度计算 + Collectors.counting() + )); + return quarterlyCounts; + } + /** + * 查询平台企业月度注册数 + * @return + */ + @Override + public Map selectEnterpriseByMonth() { + List enterpriseInformationDOS = enterpriseInformationMapper.selectList(); + // 按月度分组并计算企业数量 + Map monthlyCounts = enterpriseInformationDOS.stream() + .collect(Collectors.groupingBy( + enterprise -> enterprise.getCreateTime().getYear() + "-" + + ((enterprise.getCreateTime().getMonthValue())), + Collectors.counting() + )); + return monthlyCounts; + } + private void validateLeaveExists(Long id) { if (enterpriseInformationMapper.selectById(id) == null) { throw exception(ENTERPRISE_INFORMATION_NOT_EXISTS);