Browse Source

查询市级账号/区县级账号/镇街级账号/社区级账号登录次数

dev
yinzuomei 2 years ago
parent
commit
bee178b830
  1. 35
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/LoginLogCountByLevelFormDTO.java
  2. 29
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/LoginLogCountByLevelResultDTO.java
  3. 18
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java
  4. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  5. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffLoginLogService.java
  6. 17
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  7. 102
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java

35
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/LoginLogCountByLevelFormDTO.java

@ -0,0 +1,35 @@
package com.epmet.dto.form.yt;
import lombok.Data;
import java.util.Date;
/**
* @Description 账号登录情况查询市级账号/区县级账号/镇街级账号/社区级账号登录次数入参dto
* @Author yzm
* @Date 2023/4/6 10:09
*/
@Data
public class LoginLogCountByLevelFormDTO {
/**
* 所选择的组织id
*/
private String orgId;
/**
* 组织类型
*/
private String orgType;
/**
* 开始日期yyyy-MM-dd
*/
private Date startDate;
/**
* 截止日期yyyy-MM-dd
*/
private Date endDate;
}

29
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/LoginLogCountByLevelResultDTO.java

@ -0,0 +1,29 @@
package com.epmet.dto.result.yt;
import lombok.Data;
/**
* @Description 账号登录情况查询市级账号/区县级账号/镇街级账号/社区级账号登录次数返参dto
* @Author yzm
* @Date 2023/4/6 10:13
*/
@Data
public class LoginLogCountByLevelResultDTO {
/**
* 市级账号登录总次数-1时不展示
*/
private Integer cityCount;
/**
* 区县级账号登录总次数-1时不展示
*/
private Integer districtCount;
/**
* 镇街级账号登录总次数-1时不展示
*/
private Integer streetCount;
/**
* 社区级账号登录总次数-1时不展示
*/
private Integer communityCount;
}

18
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java

@ -1,7 +1,12 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.yt.LoginLogCountByLevelFormDTO;
import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO;
import com.epmet.service.StaffLoginLogService; import com.epmet.service.StaffLoginLogService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -19,4 +24,17 @@ public class StaffLoginLogController {
@Autowired @Autowired
private StaffLoginLogService staffLoginLogService; private StaffLoginLogService staffLoginLogService;
/**
* 返回市级账号登录总次数区县级账号登录总次数镇街级账号登录总次数社区级账号登录总次数
*
* @param formDTO
* @return
*/
@PostMapping("count-level")
public Result<LoginLogCountByLevelResultDTO> countLevel(@RequestBody LoginLogCountByLevelFormDTO formDTO) {
return new Result<LoginLogCountByLevelResultDTO>().ok(staffLoginLogService.countLevel(formDTO.getOrgId(), formDTO.getOrgType(), formDTO.getStartDate(), formDTO.getEndDate()));
}
} }

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -18,7 +18,6 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -355,4 +354,12 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @Date 2022/11/30 22:41 * @Date 2022/11/30 22:41
**/ **/
Result<List<CurrentUserCommunityInfoResultDTO>> getCurrentUserCommunityInfo(TokenDto tokenDTO); Result<List<CurrentUserCommunityInfoResultDTO>> getCurrentUserCommunityInfo(TokenDto tokenDTO);
/**
* 返回组织的orgIdPath包含自身
*
* @param orgId
* @return
*/
String getOrgIdPath(String orgId);
} }

11
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffLoginLogService.java

@ -1,6 +1,7 @@
package com.epmet.service; package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO;
import com.epmet.entity.StaffLoginLogEntity; import com.epmet.entity.StaffLoginLogEntity;
import java.util.Date; import java.util.Date;
@ -19,4 +20,14 @@ public interface StaffLoginLogService extends BaseService<StaffLoginLogEntity> {
*/ */
void saveLog(String staffId, Date loginTime); void saveLog(String staffId, Date loginTime);
/**
* 返回市级账号登录总次数区县级账号登录总次数镇街级账号登录总次数社区级账号登录总次数
*
* @param orgId 为空时默认当前登录用户所属组织id
* @param orgType
* @param startDate yyyy-MM-dd
* @param endDate yyyy-MM-dd
* @return
*/
LoginLogCountByLevelResultDTO countLevel(String orgId, String orgType, Date startDate, Date endDate);
} }

17
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -1607,4 +1607,21 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
return new Result<List<CurrentUserCommunityInfoResultDTO>>().ok(list); return new Result<List<CurrentUserCommunityInfoResultDTO>>().ok(list);
} }
/**
* 返回组织的orgIdPath包含自身
*
* @param orgId
* @return
*/
@Override
public String getOrgIdPath(String orgId) {
CustomerAgencyEntity customerAgencyEntity = baseDao.selectById(orgId);
if (null == customerAgencyEntity) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode());
}
if (StringUtils.isBlank(customerAgencyEntity.getPid()) || NumConstant.ZERO_STR.equals(customerAgencyEntity.getPid())) {
return orgId;
}
return customerAgencyEntity.getPids().concat(StrConstant.COLON).concat(orgId);
}
} }

102
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java

@ -1,15 +1,19 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.dao.StaffLoginLogDao; import com.epmet.dao.StaffLoginLogDao;
import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO;
import com.epmet.entity.StaffLoginLogEntity; import com.epmet.entity.StaffLoginLogEntity;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerAgencyService;
@ -69,7 +73,105 @@ public class StaffLoginLogServiceImpl extends BaseServiceImpl<StaffLoginLogDao,
} }
/**
* 返回市级账号登录总次数区县级账号登录总次数镇街级账号登录总次数社区级账号登录总次数
*
* @param orgId 为空时默认当前登录用户所属组织id
* @param orgType :组织级别社区级community 街道:street,区县级: district,市级: city;省级:province
* @param startDate yyyy-MM-dd
* @param endDate yyyy-MM-dd
* @return
*/
@Override
public LoginLogCountByLevelResultDTO countLevel(String orgId, String orgType, Date startDate, Date endDate) {
if (StringUtils.isBlank(orgId)) {
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId());
orgId = staffInfoCacheResult.getAgencyId();
orgType = staffInfoCacheResult.getLevel();
}
String orgIdPath = SpringContextUtils.getBean(CustomerAgencyService.class).getOrgIdPath(orgId);
LoginLogCountByLevelResultDTO resultDTO = new LoginLogCountByLevelResultDTO();
if (Constant.CITY.equals(orgType)) {
//市级账号登录
LambdaQueryWrapper<StaffLoginLogEntity> cityWrapper = new LambdaQueryWrapper<>();
cityWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setCityCount(baseDao.selectCount(cityWrapper));
// 市下面区县账号
LambdaQueryWrapper<StaffLoginLogEntity> districtWrapper = new LambdaQueryWrapper<>();
districtWrapper.eq(StaffLoginLogEntity::getPid, orgId)
.eq(StaffLoginLogEntity::getAgencyLevel,Constant.DISTRICT)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setDistrictCount(baseDao.selectCount(districtWrapper));
// 市级下面所有街道
LambdaQueryWrapper<StaffLoginLogEntity> streetWrapper = new LambdaQueryWrapper<>();
streetWrapper.like(StaffLoginLogEntity::getOrgIdPath, orgIdPath)
.eq(StaffLoginLogEntity::getAgencyLevel,Constant.STREET)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setStreetCount(baseDao.selectCount(streetWrapper));
// 市级下面所有社区
LambdaQueryWrapper<StaffLoginLogEntity> communityWrapper = new LambdaQueryWrapper<>();
communityWrapper.like(StaffLoginLogEntity::getOrgIdPath, orgIdPath)
.eq(StaffLoginLogEntity::getAgencyLevel,Constant.COMMUNITY)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setCommunityCount(baseDao.selectCount(communityWrapper));
} else if (Constant.DISTRICT.equals(orgType)) {
resultDTO.setCityCount(NumConstant.ONE_NEG);
//只展示本区县的登录情况
LambdaQueryWrapper<StaffLoginLogEntity> districtWrapper = new LambdaQueryWrapper<>();
districtWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setDistrictCount(baseDao.selectCount(districtWrapper));
// 区县下所有的街道
LambdaQueryWrapper<StaffLoginLogEntity> streetWrapper = new LambdaQueryWrapper<>();
streetWrapper.like(StaffLoginLogEntity::getOrgIdPath, orgIdPath)
.eq(StaffLoginLogEntity::getAgencyLevel,Constant.STREET)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setStreetCount(baseDao.selectCount(streetWrapper));
// 去线下所有社区
LambdaQueryWrapper<StaffLoginLogEntity> communityWrapper = new LambdaQueryWrapper<>();
communityWrapper.like(StaffLoginLogEntity::getOrgIdPath, orgIdPath)
.eq(StaffLoginLogEntity::getAgencyLevel,Constant.COMMUNITY)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setCommunityCount(baseDao.selectCount(communityWrapper));
} else if (Constant.STREET.equals(orgType)) {
resultDTO.setCityCount(NumConstant.ONE_NEG);
resultDTO.setDistrictCount(NumConstant.ONE_NEG);
// 只展示本街道的登录情况
LambdaQueryWrapper<StaffLoginLogEntity> streetWrapper = new LambdaQueryWrapper<>();
streetWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setStreetCount(baseDao.selectCount(streetWrapper));
// 街道下所有社区
LambdaQueryWrapper<StaffLoginLogEntity> communityWrapper = new LambdaQueryWrapper<>();
communityWrapper.like(StaffLoginLogEntity::getOrgIdPath, orgIdPath)
.eq(StaffLoginLogEntity::getAgencyLevel,Constant.COMMUNITY)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setCommunityCount(baseDao.selectCount(communityWrapper));
} else if (Constant.COMMUNITY.equals(orgType)) {
resultDTO.setCityCount(NumConstant.ONE_NEG);
resultDTO.setDistrictCount(NumConstant.ONE_NEG);
resultDTO.setStreetCount(NumConstant.ONE_NEG);
// 只展示本社区的登录情况
LambdaQueryWrapper<StaffLoginLogEntity> communityWrapper = new LambdaQueryWrapper<>();
communityWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId)
.between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate);
resultDTO.setCommunityCount(baseDao.selectCount(communityWrapper));
}
return resultDTO;
}
} }
Loading…
Cancel
Save