From 7b662fad1a70e20884929c596e1031072a8b3e38 Mon Sep 17 00:00:00 2001 From: lc <15038716315@163.com> Date: Wed, 19 Jun 2024 14:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E4=BF=A1=E6=81=AF=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=20=E6=9F=A5=E8=AF=A2=E4=BC=81=E4=B8=9A=E5=B9=B4?= =?UTF-8?q?=E5=BA=A6=E3=80=81=E6=9C=88=E5=BA=A6=E3=80=81=E5=AD=A3=E5=BA=A6?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EnterpriseInformationController.java | 20 ++++++ .../EnterpriseInformationService.java | 18 +++++ .../EnterpriseInformationServiceImpl.java | 67 +++++++++++++++++++ 3 files changed, 105 insertions(+) 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);