企业信息统计 查询企业季度注册数返回格式月份调整
This commit is contained in:
parent
11e32ccd33
commit
698eaa41da
@ -116,9 +116,9 @@ public class EnterpriseInformationController {
|
|||||||
|
|
||||||
@GetMapping("/selectEnterpriseByQuarter")
|
@GetMapping("/selectEnterpriseByQuarter")
|
||||||
@Operation(summary = "查询平台企业季度注册数")
|
@Operation(summary = "查询平台企业季度注册数")
|
||||||
public CommonResult<Map<String,Long>> selectEnterpriseByQuarter(){
|
public CommonResult<List<StatisticsResultData>> selectEnterpriseByQuarter(){
|
||||||
Map<String, Long> stringLongMap = enterpriseInformationService.selectEnterpriseByQuarter();
|
List<StatisticsResultData> statisticsResultData = enterpriseInformationService.selectEnterpriseByQuarter();
|
||||||
return success(stringLongMap);
|
return success(statisticsResultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/selectEnterpriseByMonth")
|
@GetMapping("/selectEnterpriseByMonth")
|
||||||
|
@ -95,7 +95,7 @@ public interface EnterpriseInformationService {
|
|||||||
* 查询平台企业季度注册数
|
* 查询平台企业季度注册数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Long> selectEnterpriseByQuarter();
|
List<StatisticsResultData> selectEnterpriseByQuarter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询平台企业月度注册数
|
* 查询平台企业月度注册数
|
||||||
|
@ -283,7 +283,7 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Long> selectEnterpriseByQuarter() {
|
public List<StatisticsResultData> selectEnterpriseByQuarter() {
|
||||||
List<EnterpriseInformationDO> enterpriseInformationDOS = enterpriseInformationMapper.selectList();
|
List<EnterpriseInformationDO> enterpriseInformationDOS = enterpriseInformationMapper.selectList();
|
||||||
// 按季度分组并计算企业数量
|
// 按季度分组并计算企业数量
|
||||||
Map<String, Long> quarterlyCounts = enterpriseInformationDOS.stream()
|
Map<String, Long> quarterlyCounts = enterpriseInformationDOS.stream()
|
||||||
@ -292,8 +292,63 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe
|
|||||||
((enterprise.getCreateTime().getMonthValue() - 1) / 3 + 1), // 季度计算
|
((enterprise.getCreateTime().getMonthValue() - 1) / 3 + 1), // 季度计算
|
||||||
Collectors.counting()
|
Collectors.counting()
|
||||||
));
|
));
|
||||||
return quarterlyCounts;
|
LocalDate today = LocalDate.now();
|
||||||
|
int year = today.getYear();//当前年份
|
||||||
|
Map<String, Long> filteredCounts = quarterlyCounts.entrySet().stream()
|
||||||
|
.filter(entry -> entry.getKey().contains(year+""))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
entry -> entry.getKey().substring(5),
|
||||||
|
Map.Entry::getValue
|
||||||
|
));
|
||||||
|
List<StatisticsResultData> list = new ArrayList<>();
|
||||||
|
extracted(filteredCounts, list);
|
||||||
|
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
|
* @return
|
||||||
@ -317,7 +372,16 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe
|
|||||||
Map.Entry::getValue
|
Map.Entry::getValue
|
||||||
));
|
));
|
||||||
List<StatisticsResultData> list = new ArrayList<>();
|
List<StatisticsResultData> list = new ArrayList<>();
|
||||||
|
disposeMonthData(filteredCounts, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理月度注册数据
|
||||||
|
* @param filteredCounts
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
private static void disposeMonthData(Map<String, Long> filteredCounts, List<StatisticsResultData> list) {
|
||||||
StatisticsResultData january = new StatisticsResultData();
|
StatisticsResultData january = new StatisticsResultData();
|
||||||
january.setName("analysis.january");
|
january.setName("analysis.january");
|
||||||
if(filteredCounts.containsKey("1")){
|
if(filteredCounts.containsKey("1")){
|
||||||
@ -426,8 +490,6 @@ public class EnterpriseInformationServiceImpl implements EnterpriseInformationSe
|
|||||||
list.add(october);
|
list.add(october);
|
||||||
list.add(november);
|
list.add(november);
|
||||||
list.add(december);
|
list.add(december);
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user