mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
+10
@@ -9,7 +9,9 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 多组织")
|
||||
@@ -26,4 +28,12 @@ public interface OrganApi {
|
||||
@Parameter(name = "id", description = "组织编号", required = true, example = "1024")
|
||||
CommonResult<Boolean> validOrgan(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/total/org")
|
||||
@Operation(summary = "组织总数查询")
|
||||
CommonResult<Map<String, Integer>> getOrgTotal();
|
||||
|
||||
@GetMapping(PREFIX + "/separate/org")
|
||||
@Operation(summary = "新增、注销组织数量统计")
|
||||
CommonResult<Map<String, Object>> getOrgSeparate(@RequestParam("time") LocalDate[] createTime, @RequestParam("unit")Integer unit);
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -74,4 +74,11 @@ public interface AdminUserApi {
|
||||
@Parameter(name = "organIds", description = "组织id列表", example = "1,3", required = true)
|
||||
CommonResult<List<OrganAdminUserRespDTO>> getOrganAdminByOrganIds(@RequestParam("id") Collection<Long> organIds);
|
||||
|
||||
@GetMapping(PREFIX + "/total/user")
|
||||
@Operation(summary = "用户总数")
|
||||
CommonResult<Map<String, Integer>> getUserTotal();
|
||||
|
||||
@GetMapping(PREFIX + "/total/userAct")
|
||||
@Operation(summary = "用户活跃数")
|
||||
CommonResult<Map<String, Integer>> getUserActTotal();
|
||||
}
|
||||
|
||||
+12
@@ -6,7 +6,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@@ -28,4 +30,14 @@ public class OrganApiImpl implements OrganApi {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Map<String, Integer>> getOrgTotal() {
|
||||
return success(organService.orgTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Map<String, Object>> getOrgSeparate(LocalDate[] createTime, Integer unit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
@@ -64,5 +65,15 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
return success(userService.getOrganAdminByOrganIds(organIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Map<String, Integer>> getUserTotal() {
|
||||
return success(userService.userTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Map<String, Integer>> getUserActTotal() {
|
||||
return success(userService.userActTotal());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+26
@@ -4,11 +4,15 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
|
||||
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -55,6 +59,27 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
|
||||
}
|
||||
|
||||
|
||||
default Integer selectOrgCount() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>()
|
||||
.eq(OrganizationDO::getUpdateTime, OrderDeletedEnum.NOT_DELETED.getStatus())));
|
||||
}
|
||||
|
||||
default Integer selectOrgCountAdd() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>()
|
||||
.eq(OrganizationDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())
|
||||
.between(OrganizationDO::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT),
|
||||
LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59)))));
|
||||
}
|
||||
|
||||
default Integer selectOrgCountDel() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>()
|
||||
.eq(OrganizationDO::getDeleted, OrderDeletedEnum.DELETED.getStatus())
|
||||
.between(OrganizationDO::getDeleted, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT),
|
||||
LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59)))));
|
||||
}
|
||||
|
||||
Integer selectOrgSilentCount(@Param("dateTime")LocalDateTime dateTime);
|
||||
|
||||
|
||||
default List<OrganizationDO> selectOrganList(Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<OrganizationDO>()
|
||||
@@ -67,4 +92,5 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+32
@@ -2,17 +2,23 @@ package com.cf.imes.module.system.dal.mysql.user;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
|
||||
import com.cf.imes.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -104,5 +110,31 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
.in(AdminUserDO::getId, userIds));
|
||||
}
|
||||
|
||||
default Integer selectUserCount() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())));
|
||||
}
|
||||
|
||||
default Integer selectUserCountAdd() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())
|
||||
.between(AdminUserDO::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT),
|
||||
LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59)))));
|
||||
}
|
||||
|
||||
default Integer selectUserCountDel() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.DELETED.getStatus())
|
||||
.between(AdminUserDO::getUpdateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT),
|
||||
LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59)))));
|
||||
}
|
||||
|
||||
Integer selectUserSilentCount(@Param("dateTime")LocalDateTime dateTime);
|
||||
|
||||
default Integer selectUserActCountTime(LocalDateTime startTime, LocalDateTime endTIme) {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())
|
||||
.eq(AdminUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.between(AdminUserDO::getCreateTime, startTime, endTIme)));
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -12,6 +12,7 @@ import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -130,4 +131,9 @@ public interface OrganService {
|
||||
void validOrgan(Long id);
|
||||
|
||||
List<OrganSimpleRespVO> getSimpleOrganList(String name);
|
||||
|
||||
/**
|
||||
* 组织总数统计
|
||||
*/
|
||||
Map<String, Integer> orgTotal();
|
||||
}
|
||||
|
||||
+23
-3
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.service.organ;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -43,9 +44,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
@@ -352,4 +351,25 @@ public class OrganServiceImpl implements OrganService {
|
||||
return organProperties == null || Boolean.FALSE.equals(organProperties.getEnable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> orgTotal() {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
|
||||
// 组织总数
|
||||
Integer orgTotal = organMapper.selectOrgCount();
|
||||
map.put("orgTotal", orgTotal);
|
||||
// 当日新增数
|
||||
Integer orgAdd = organMapper.selectOrgCountAdd();
|
||||
map.put("orgAdd", orgAdd);
|
||||
// 当日状态-删除
|
||||
Integer orgDel = organMapper.selectOrgCountDel();
|
||||
map.put("orgDel", orgDel);
|
||||
// 当日沉寂数 (组织中所有用户30天未登录)
|
||||
// 获得30天前的时间,赋值时间为0:00:00
|
||||
Date date = DateUtil.offsetDay(new Date(), -30);
|
||||
Integer orgSilent = organMapper.selectOrgSilentCount(DateUtil.beginOfDay(date).toLocalDateTime());
|
||||
map.put("orgSilent", orgSilent);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -232,4 +232,14 @@ public interface AdminUserService {
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<OrganAdminUserRespDTO> getOrganAdminByOrganIds(Collection<Long> organIds);
|
||||
|
||||
/**
|
||||
* 用户总数统计
|
||||
*/
|
||||
Map<String, Integer> userTotal();
|
||||
|
||||
/**
|
||||
* 用户活跃数统计
|
||||
*/
|
||||
Map<String, Integer> userActTotal();
|
||||
}
|
||||
|
||||
+51
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.service.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
@@ -47,7 +48,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -578,4 +581,52 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
throw exception(USER_ME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> userTotal() {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
|
||||
// 用户总数
|
||||
Integer userTotal = userMapper.selectUserCount();
|
||||
map.put("userTotal", userTotal);
|
||||
// 当日新增数
|
||||
Integer userTodayAdd = userMapper.selectUserCountAdd();
|
||||
map.put("userTodayAdd", userTodayAdd);
|
||||
// 当日状态-停止数
|
||||
Integer userTodayDel = userMapper.selectUserCountDel();
|
||||
map.put("userTodayDel", userTodayDel);
|
||||
// 当日沉寂数 (30天未登录)
|
||||
Date date = DateUtil.offsetDay(new Date(), -30);
|
||||
Integer userTodaySilent = userMapper.selectUserSilentCount(DateUtil.beginOfDay(date).toLocalDateTime());
|
||||
map.put("userTodaySilent", userTodaySilent);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> userActTotal() {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
|
||||
LocalDateTime startTime = getFirstDayOfMonth();
|
||||
LocalDateTime endTIme = LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59));
|
||||
// 用户月活跃数
|
||||
Integer userMonthAct = userMapper.selectUserActCountTime(startTime, endTIme);
|
||||
map.put("userMonthAct", userMonthAct);
|
||||
// 用户日活跃数
|
||||
Integer userDayAct = userMapper.selectUserActCountTime(LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0)), endTIme);
|
||||
map.put("userDayAct", userDayAct);
|
||||
return map;
|
||||
}
|
||||
|
||||
// 获得此月第一天日期
|
||||
public LocalDateTime getFirstDayOfMonth() {
|
||||
// 获取当前日期
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
// 获取当前月份的第一天
|
||||
LocalDate firstDayOfMonth = today.withDayOfMonth(1);
|
||||
|
||||
// 将时间设置为 0 点
|
||||
return LocalDateTime.of(firstDayOfMonth, LocalTime.MIDNIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.organ.OrganMapper">
|
||||
|
||||
<select id="selectOrgSilentCount" resultType="java.lang.Integer">
|
||||
WITH NoLoginOrgs AS (
|
||||
SELECT DISTINCT o.id
|
||||
FROM system_organization o
|
||||
LEFT JOIN system_users ul ON o.id = ul.organ_id
|
||||
AND Date (#{dateTime}) > ul.login_date
|
||||
AND ul.deleted = 0
|
||||
WHERE o.deleted =0
|
||||
|
||||
)
|
||||
|
||||
-- 查询这些沉寂组织的数量
|
||||
SELECT COUNT(*) AS count
|
||||
FROM NoLoginOrgs;
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.organ.OrganMapper">
|
||||
|
||||
<select id="selectUserSilentCount" resultType="java.lang.Integer">
|
||||
SELECT DISTINCT COUNT(*) AS count
|
||||
FROM system_users
|
||||
WHERE deleted =0
|
||||
AND Date (#{dateTime})> ul.login_date
|
||||
AND deleted = 0
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user