企业信息统计 查询企业年度、季度、月度注册数返回格式调整
This commit is contained in:
		
							parent
							
								
									698eaa41da
								
							
						
					
					
						commit
						d4dc59d94e
					
				| @ -109,8 +109,8 @@ public class EnterpriseInformationController { | ||||
|     } | ||||
|     @GetMapping("/selectEnterpriseByYear") | ||||
|     @Operation(summary = "查询平台企业年度注册数") | ||||
|     public CommonResult<Map<Integer,Long>> selectEnterpriseByYear(){ | ||||
|         Map<Integer, Long> integerLongMap = enterpriseInformationService.selectEnterpriseByYear(); | ||||
|     public CommonResult<List<StatisticsResultData>> selectEnterpriseByYear(){ | ||||
|         List<StatisticsResultData> integerLongMap = enterpriseInformationService.selectEnterpriseByYear(); | ||||
|         return success(integerLongMap); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -89,7 +89,7 @@ public interface EnterpriseInformationService { | ||||
|      * 查询平台企业年度注册数 | ||||
|      * @return | ||||
|      */ | ||||
|     Map<Integer, Long> selectEnterpriseByYear(); | ||||
|     List<StatisticsResultData> selectEnterpriseByYear(); | ||||
| 
 | ||||
|     /** | ||||
|      * 查询平台企业季度注册数 | ||||
|  | ||||
| @ -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<Integer, Long> selectEnterpriseByYear() { | ||||
|     public List<StatisticsResultData> selectEnterpriseByYear() { | ||||
|         List<EnterpriseInformationDO> enterpriseInformationDOS = enterpriseInformationMapper.selectList(); | ||||
| 
 | ||||
|         // 按年分组并计算企业数量 | ||||
|         Map<Integer, Long> collect = enterpriseInformationDOS.stream() | ||||
|                 .collect(Collectors.groupingBy(enterprise -> enterprise.getCreateTime().getYear(), Collectors.counting())); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //// 按月分组并计算企业数量 | ||||
| //        Map<YearMonth, Long> monthlyCounts = enterpriseInformationDOS.stream() | ||||
| //                .collect(Collectors.groupingBy( | ||||
| //                                EnterpriseInformationDO::getCreateTime::toYearMonth, // 注意这里需要修改以适配Java的语法 | ||||
| //                        Collectors.counting() | ||||
| //                )); | ||||
| // | ||||
| //// 注意:上面的toYearMonth是一个假设的方法,Java中并没有这样的方法直接在Lambda表达式中使用 | ||||
| //// 你需要创建一个Function来实现这个转换 | ||||
| //        Function<LocalDate, YearMonth> toYearMonth = LocalDate::toYearMonth; | ||||
| //        Map<YearMonth, Long> monthlyCountsCorrect = enterpriseInformationDOS.stream() | ||||
| //                .collect(Collectors.groupingBy( | ||||
| //                        toYearMonth, // 使用上面定义的Function | ||||
| //                        Collectors.counting() | ||||
| //                )); | ||||
| 
 | ||||
|         return collect; | ||||
|         Map<String, Long> collect = enterpriseInformationDOS.stream() | ||||
|                 .collect(Collectors.groupingBy(enterprise -> String.valueOf(enterprise.getCreateTime().getYear()), Collectors.counting())); | ||||
|         List<StatisticsResultData> list = new ArrayList<>(); | ||||
|         List<DictDataDO> dictDataDOS = dictDataService.getDictDataListByDictType("year"); | ||||
|         disposeData(collect, list, dictDataDOS); | ||||
|         return list; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -301,54 +289,11 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe | ||||
|                         Map.Entry::getValue | ||||
|                 )); | ||||
|         List<StatisticsResultData> list = new ArrayList<>(); | ||||
|         extracted(filteredCounts, list); | ||||
|         List<DictDataDO> dictDataDOS = dictDataService.getDictDataListByDictType("quarter"); | ||||
|         disposeData(filteredCounts, list, dictDataDOS); | ||||
|         return list; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 处理季度注册数据 | ||||
|      * @param filteredCounts | ||||
|      * @param list | ||||
|      */ | ||||
|     private static void extracted(Map<String, Long> filteredCounts, List<StatisticsResultData> 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<StatisticsResultData> list = new ArrayList<>(); | ||||
|         disposeMonthData(filteredCounts, list); | ||||
| 
 | ||||
|         List<DictDataDO> dictDataDOS = dictDataService.getDictDataListByDictType("month"); | ||||
|         disposeData(filteredCounts, list, dictDataDOS); | ||||
|         return list; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 处理月度注册数据 | ||||
|      * 处理注册数据 | ||||
|      * @param filteredCounts | ||||
|      * @param list | ||||
|      * @param dictDataDOS | ||||
|      */ | ||||
|     private static void disposeMonthData(Map<String, Long> filteredCounts, List<StatisticsResultData> 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<String, Long> filteredCounts, List<StatisticsResultData> list, List<DictDataDO> 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); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user