修正案件统计值#573

master
李一帆 2025-04-09 17:07:19 +08:00
parent 73fc33f5b9
commit 23f4636aee
1 changed files with 32 additions and 22 deletions

View File

@ -218,36 +218,46 @@ public class SzCaseController extends AbstractCommonFileController{
public R<List<SzCaseStatisticsVo>> statisticsNum(@Schema(name = "年份") @PathVariable("year") Integer year) {
LambdaQueryChainWrapper<SzCase> query = service.lambdaQuery();
query.ge(SzCase::getCreateTime, DateUtil.beginOfYearToDate(year));
query.ge(SzCase::getCaseDate, DateUtil.beginOfYearToDate(year));
query.le(SzCase::getCreateTime, DateUtil.endOfYearToDate(year));
query.le(SzCase::getCaseDate, DateUtil.endOfYearToDate(year));
List<SzCaseStatisticsVo> vos = Lists.newArrayList();
List<SzCase> list = query.list();
Calendar calendar = Calendar.getInstance();
int currYear = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
if(year.intValue() != currYear){
calendar.set(Calendar.YEAR,year);
month = 12;
}
final int finalMonth = month;
for (int i = 1; i <= finalMonth; i++) {
int finalI = i;
long count = 0;
if(CollectionUtils.isNotEmpty(list)){
count = list.stream()
.filter(item ->
{
calendar.setTime(item.getCaseDate());
return finalMonth == finalI;
})
.count();
}
vos.add(new SzCaseStatisticsVo(i,null,Integer.valueOf(String.valueOf(count))));
for (int i = 0; i < 12; i++) {
int month = i;
long cnt = list.stream().filter(item -> {
calendar.setTime(item.getCaseDate());
return month == calendar.get(Calendar.MONTH);
}).count();
vos.add(new SzCaseStatisticsVo(month + 1,null,Integer.valueOf(String.valueOf(cnt))));
}
//
// Calendar calendar = Calendar.getInstance();
// int currYear = calendar.get(Calendar.YEAR);
// int month = calendar.get(Calendar.MONTH) + 1;
// if(year.intValue() != currYear){
// calendar.set(Calendar.YEAR,year);
// month = 12;
// }
// final int finalMonth = month;
// for (int i = 1; i <= finalMonth; i++) {
// int finalI = i;
// long count = 0;
// if(CollectionUtils.isNotEmpty(list)){
// count = list.stream()
// .filter(item ->
// {
// calendar.setTime(item.getCaseDate());
// return finalMonth == finalI;
// })
// .count();
// }
// vos.add(new SzCaseStatisticsVo(i,null,Integer.valueOf(String.valueOf(count))));
// }
return R.ok(vos);
}