|
|
@ -1,15 +1,19 @@ |
|
|
|
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.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
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.SpringContextUtils; |
|
|
|
import com.epmet.dao.StaffLoginLogDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
|
import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO; |
|
|
|
import com.epmet.entity.StaffLoginLogEntity; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |