From d4dc59d94e6aa814af2d9fe6bd6d2c1ea70b7d2b Mon Sep 17 00:00:00 2001 From: lc <15038716315@163.com> Date: Fri, 21 Jun 2024 14:08:05 +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=E5=AD=A3=E5=BA=A6=E3=80=81=E6=9C=88=E5=BA=A6?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=95=B0=E8=BF=94=E5=9B=9E=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EnterpriseInformationController.java | 4 +- .../EnterpriseInformationService.java | 2 +- .../EnterpriseInformationServiceImpl.java | 210 +++--------------- 3 files changed, 34 insertions(+), 182 deletions(-) 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 48f85ab..03bb43b 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 @@ -109,8 +109,8 @@ public class EnterpriseInformationController { } @GetMapping("/selectEnterpriseByYear") @Operation(summary = "查询平台企业年度注册数") - public CommonResult> selectEnterpriseByYear(){ - Map integerLongMap = enterpriseInformationService.selectEnterpriseByYear(); + public CommonResult> selectEnterpriseByYear(){ + List integerLongMap = enterpriseInformationService.selectEnterpriseByYear(); return success(integerLongMap); } 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 09426a0..a4dd92a 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 @@ -89,7 +89,7 @@ public interface EnterpriseInformationService { * 查询平台企业年度注册数 * @return */ - Map selectEnterpriseByYear(); + List selectEnterpriseByYear(); /** * 查询平台企业季度注册数 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 93755e4..915f717 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 @@ -15,6 +15,8 @@ import cn.iocoder.yudao.module.fta.dal.dataobject.enterpriseinformation.Enterpri import cn.iocoder.yudao.module.fta.dal.dataobject.enterpriseinformation.StatisticsResultData; import cn.iocoder.yudao.module.fta.dal.mysql.enterpriseinformation.CredentialManagementMapper; import cn.iocoder.yudao.module.fta.dal.mysql.enterpriseinformation.EnterpriseInformationMapper; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; +import cn.iocoder.yudao.module.system.service.dict.DictDataService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.springframework.stereotype.Service; @@ -55,6 +57,9 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe @Resource private BpmProcessInstanceApi processInstanceApi; + @Resource + private DictDataService dictDataService; + @Override public Long createEnterpriseInformation(EnterpriseInformationSaveReqVO createReqVO) { // 插入 企业基础信息填报 @@ -249,33 +254,16 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe * @return */ @Override - public Map selectEnterpriseByYear() { + public List 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; + Map collect = enterpriseInformationDOS.stream() + .collect(Collectors.groupingBy(enterprise -> String.valueOf(enterprise.getCreateTime().getYear()), Collectors.counting())); + List list = new ArrayList<>(); + List dictDataDOS = dictDataService.getDictDataListByDictType("year"); + disposeData(collect, list, dictDataDOS); + return list; } /** @@ -301,54 +289,11 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe Map.Entry::getValue )); List list = new ArrayList<>(); - extracted(filteredCounts, list); + List dictDataDOS = dictDataService.getDictDataListByDictType("quarter"); + disposeData(filteredCounts, list, dictDataDOS); return list; } - /** - * 处理季度注册数据 - * @param filteredCounts - * @param list - */ - private static void extracted(Map filteredCounts, List list) { - StatisticsResultData quarterOne = new StatisticsResultData(); - quarterOne.setName("第一季度"); - if(filteredCounts.containsKey("1")){ - quarterOne.setValue(filteredCounts.get("1")); - }else { - quarterOne.setValue(0L); - } - - StatisticsResultData quarterTwo = new StatisticsResultData(); - quarterTwo.setName("第二季度"); - if(filteredCounts.containsKey("2")){ - quarterTwo.setValue(filteredCounts.get("2")); - }else { - quarterTwo.setValue(0L); - } - - StatisticsResultData quarterThree = new StatisticsResultData(); - quarterThree.setName("第三季度"); - if(filteredCounts.containsKey("3")){ - quarterThree.setValue(filteredCounts.get("3")); - }else { - quarterThree.setValue(0L); - } - - StatisticsResultData quarterFour = new StatisticsResultData(); - quarterFour.setName("第四季度"); - if(filteredCounts.containsKey("4")){ - quarterFour.setValue(filteredCounts.get("4")); - }else { - quarterFour.setValue(0L); - } - - list.add(quarterOne); - list.add(quarterTwo); - list.add(quarterThree); - list.add(quarterFour); - } - /** * 查询平台企业月度注册数 * @return @@ -372,124 +317,31 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe Map.Entry::getValue )); List list = new ArrayList<>(); - disposeMonthData(filteredCounts, list); + + List dictDataDOS = dictDataService.getDictDataListByDictType("month"); + disposeData(filteredCounts, list, dictDataDOS); return list; } /** - * 处理月度注册数据 + * 处理注册数据 * @param filteredCounts * @param list + * @param dictDataDOS */ - private static void disposeMonthData(Map filteredCounts, List list) { - StatisticsResultData january = new StatisticsResultData(); - january.setName("analysis.january"); - if(filteredCounts.containsKey("1")){ - january.setValue(filteredCounts.get("1")); - }else { - january.setValue(0L); + private static void disposeData(Map filteredCounts, List list, List dictDataDOS) { + for (DictDataDO data: dictDataDOS + ) { + StatisticsResultData statisticsResultData = new StatisticsResultData(); + if(filteredCounts.containsKey(data.getLabel())){ + statisticsResultData.setValue(filteredCounts.get(data.getLabel())); + statisticsResultData.setName(data.getValue()); + }else { + statisticsResultData.setValue(0L); + statisticsResultData.setName(data.getValue()); + } + list.add(statisticsResultData); } - - StatisticsResultData february = new StatisticsResultData(); - february.setName("analysis.february"); - if(filteredCounts.containsKey("2")){ - february.setValue(filteredCounts.get("2")); - }else { - february.setValue(0L); - } - - StatisticsResultData march = new StatisticsResultData(); - march.setName("analysis.march"); - if(filteredCounts.containsKey("3")){ - march.setValue(filteredCounts.get("3")); - }else { - march.setValue(0L); - } - - StatisticsResultData april = new StatisticsResultData(); - april.setName("analysis.april"); - if(filteredCounts.containsKey("4")){ - april.setValue(filteredCounts.get("4")); - }else { - april.setValue(0L); - } - - StatisticsResultData may = new StatisticsResultData(); - may.setName("analysis.may"); - if(filteredCounts.containsKey("5")){ - may.setValue(filteredCounts.get("5")); - }else { - may.setValue(0L); - } - - StatisticsResultData june = new StatisticsResultData(); - june.setName("analysis.june"); - if(filteredCounts.containsKey("6")){ - june.setValue(filteredCounts.get("6")); - }else { - june.setValue(0L); - } - - StatisticsResultData july = new StatisticsResultData(); - july.setName("analysis.july"); - if(filteredCounts.containsKey("7")){ - july.setValue(filteredCounts.get("7")); - }else { - july.setValue(0L); - } - - StatisticsResultData august = new StatisticsResultData(); - august.setName("analysis.august"); - if(filteredCounts.containsKey("8")){ - august.setValue(filteredCounts.get("8")); - }else { - august.setValue(0L); - } - - StatisticsResultData september = new StatisticsResultData(); - september.setName("analysis.september"); - if(filteredCounts.containsKey("9")){ - september.setValue(filteredCounts.get("9")); - }else { - september.setValue(0L); - } - - StatisticsResultData october = new StatisticsResultData(); - october.setName("analysis.october"); - if(filteredCounts.containsKey("10")){ - october.setValue(filteredCounts.get("10")); - }else { - october.setValue(0L); - } - - StatisticsResultData november = new StatisticsResultData(); - november.setName("analysis.november"); - if(filteredCounts.containsKey("11")){ - november.setValue(filteredCounts.get("11")); - }else { - november.setValue(0L); - } - - StatisticsResultData december = new StatisticsResultData(); - december.setName("analysis.december"); - if(filteredCounts.containsKey("12")){ - december.setValue(filteredCounts.get("12")); - }else { - december.setValue(0L); - } - - list.add(january); - list.add(february); - list.add(march); - list.add(april); - list.add(may); - list.add(june); - list.add(july); - list.add(august); - list.add(september); - list.add(october); - list.add(november); - list.add(december); } /**