fix:6个月已登记统计

pg_adapter
wangxy 6 months ago
parent 4673b2f987
commit 678aac05a5

@ -3,8 +3,10 @@ package com.ruoyi.web.controller.system.count;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.StrPool;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -14,10 +16,12 @@ import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ObtainLastSixMonthsUtil;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUserPost; import com.ruoyi.system.domain.SysUserPost;
import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.domain.check.TdCheckReport;
import com.ruoyi.system.domain.count.UserCountDTO; import com.ruoyi.system.domain.count.UserCountDTO;
import com.ruoyi.system.domain.count.UserSmCountDTO; import com.ruoyi.system.domain.count.UserSmCountDTO;
import com.ruoyi.system.service.*; import com.ruoyi.system.service.*;
@ -27,10 +31,9 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.time.LocalDate;
import java.util.Arrays; import java.time.ZoneId;
import java.util.Collections; import java.util.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -188,6 +191,46 @@ public class SysUsernumController extends BaseController {
} }
/**
*
*6
* @return
*/
@PostMapping("/countCheckMonth")
@ResponseBody
public AjaxResult countCheckMonth() {
List<String> recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth();
List<Long> yAxisData = new ArrayList<>();
recentlySixMonth.forEach(month -> {
// 获取指定月份的最大日期
String lastDayOfMonth = ObtainLastSixMonthsUtil.getLastDayOfMonth(month);
// 获取指定天的最大时间
Date date = Date.from(LocalDate.parse(lastDayOfMonth).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
Date maxDayTime = ObtainLastSixMonthsUtil.getEndOfDay(date);
// 获取最小时间
date = Date.from(LocalDate.parse(month.concat(StrPool.DASHED).concat("01")).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
Date minDayTime = ObtainLastSixMonthsUtil.getStartOfDay(date);
AtomicReference<Long> yAxis = new AtomicReference<>(0L);
Integer count = new LambdaQueryChainWrapper<>(userService.getBaseMapper())
.ge(SysUser::getCreateTime, minDayTime)
.le(SysUser::getCreateTime, maxDayTime)
.eq(SysUser::getExamine,2)
.eq(SysUser::getDelFlag,0)
.count();
if(Objects.isNull(count)){
count = 0;
}
yAxis.set(Long.valueOf(count));
yAxisData.add(yAxis.get());
});
JSONObject obj = new JSONObject();
obj.put("xAxisData", recentlySixMonth.toArray());
obj.put("yAxisData", yAxisData);
return AjaxResult.success(obj);
}

Loading…
Cancel
Save