diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java index 6f8afd1418..10250f27a1 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java @@ -1,6 +1,7 @@ package com.epmet.mq.listener.listener; import com.alibaba.fastjson.JSON; +import com.epmet.auth.constants.AuthOperationConstants; import com.epmet.auth.constants.AuthOperationEnum; import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.LoginMQMsg; @@ -77,7 +78,11 @@ public class AuthOperationLogListener implements MessageListenerConcurrently { logEntity.setOperatorName(operatorInfo.getName()); logEntity.setOperatorMobile(operatorInfo.getMobile()); logEntity.setOperatingTime(msgObj.getLoginTime()); - logEntity.setContent("成功登录系统"); + if(AuthOperationConstants.LOGIN.equals(logEntity.getType())){ + logEntity.setContent("成功登录系统"); + }else{ + logEntity.setContent("成功退出系统"); + } DistributedLock distributedLock = null; RLock lock = null; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java index 87e53edcb0..bb5526afe6 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java @@ -32,6 +32,11 @@ public class CustomerStaffInfoCache implements Serializable { */ private String agencyName; + /** + * 组织级别 + */ + private String level; + /** * 2级组织名称 根据添加的来源返回(xx组织-组织/网格/部门) */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/CommunityLoginFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/CommunityLoginFormDTO.java new file mode 100644 index 0000000000..5fc00d0691 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/CommunityLoginFormDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.form.yt; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @Description 下级社区账号登录次数排名入参 + * @Author yzm + * @Date 2023/4/6 14:18 + */ +@Data +public class CommunityLoginFormDTO extends PageFormDTO { + /** + * 所选择的组织id + */ + private String orgId; + + /** + * 组织类型 + */ + private String level; + + /** + * 开始日期:yyyy-MM-dd + */ + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") + private Date startDate; + + /** + * 截止日期:yyyy-MM-dd + */ + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") + private Date endDate; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/CountActivityFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/CountActivityFormDTO.java new file mode 100644 index 0000000000..a1ef997fc0 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/CountActivityFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form.yt; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @Description 下级社区账号登录次数排名入参 + * @Author yzm + * @Date 2023/4/6 14:18 + */ +@Data +public class CountActivityFormDTO extends PageFormDTO { + /** + * 所选择的组织id + */ + private String orgId; + + /** + * 是否活跃 1 活跃 0 不活跃 + */ + private String isActivity; + + + /** + * 开始日期:yyyy-MM-dd + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startDate; + + /** + * 截止日期:yyyy-MM-dd + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endDate; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/LoginLogCountByLevelFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/LoginLogCountByLevelFormDTO.java new file mode 100644 index 0000000000..c115f530c9 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/yt/LoginLogCountByLevelFormDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.form.yt; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @Description 账号登录情况,查询市级账号/区县级账号/镇街级账号/社区级账号登录次数,入参dto + * @Author yzm + * @Date 2023/4/6 10:09 + */ +@Data +public class LoginLogCountByLevelFormDTO { + /** + * 所选择的组织id + */ + private String orgId; + + /** + * 组织类型 + */ + private String level; + + /** + * 开始日期:yyyy-MM-dd + */ + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") + private Date startDate; + + /** + * 截止日期:yyyy-MM-dd + */ + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") + private Date endDate; + +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/AccountActivityInfo.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/AccountActivityInfo.java new file mode 100644 index 0000000000..b63ed0c20f --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/AccountActivityInfo.java @@ -0,0 +1,44 @@ +package com.epmet.dto.result.yt; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * @author: qushutong + * @Date: 2023/4/6 13:33 + * @Description: 账户活跃情况 + */ +@Data +public class AccountActivityInfo implements Serializable { + private static final long serialVersionUID = -918630886413844674L; + + /** + * 组织名称 + */ + private String agencyName = ""; + + /** + * 登陆次数 + */ + private String loginCount = ""; + + /** + * 活跃账号数 + */ + private String accountActivityCount = ""; + + + /** + * 总账号数 + */ + private String accountCount = ""; + + /** + * 组织id + */ + private String agencyId = ""; + + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/ActivityTatalInfo.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/ActivityTatalInfo.java new file mode 100644 index 0000000000..a92b42661d --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/ActivityTatalInfo.java @@ -0,0 +1,30 @@ +package com.epmet.dto.result.yt; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * @author: qushutong + * @Date: 2023/4/6 13:33 + * @Description: 账户活跃总数 + */ +@Data +public class ActivityTatalInfo implements Serializable { + private static final long serialVersionUID = -918630886413844674L; + + + /** + * 不活跃账号总数 + */ + private String inactivityCount = ""; + + /** + * 活跃账号总数 + */ + private String activityCount = ""; + + + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java new file mode 100644 index 0000000000..e1cb00a765 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java @@ -0,0 +1,37 @@ +package com.epmet.dto.result.yt; + +import lombok.Data; + +/** + * @Description 下级社区账号登录次数排名 + * @Author yzm + * @Date 2023/4/6 14:15 + */ +@Data +public class CommunityLoginResultDTO { + /** + * 组织id + */ + private String agencyId; + /** + * 组织名称 + */ + private String agencyName; + /** + * 组织级别(社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province) + */ + private String agencyLevel; + /** + * 所属街道名称; + */ + private String streetName; + /** + * 所属区县名称; + */ + private String districtName; + /** + * 登录次数 + */ + private Integer count; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/LoginLogCountByLevelResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/LoginLogCountByLevelResultDTO.java new file mode 100644 index 0000000000..b1a4c33c42 --- /dev/null +++ b/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; +} + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java index 557d4d3dec..aab97c99fc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java @@ -1,9 +1,30 @@ package com.epmet.controller; +import com.alibaba.nacos.client.naming.utils.CollectionUtils; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.yt.CommunityLoginFormDTO; +import com.epmet.dto.form.yt.CountActivityFormDTO; +import com.epmet.dto.form.yt.LoginLogCountByLevelFormDTO; +import com.epmet.dto.result.yt.ActivityTatalInfo; +import com.epmet.dto.result.yt.CommunityLoginResultDTO; +import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO; +import com.epmet.excel.yt.AccountActivityExcel; +import com.epmet.excel.yt.AccountInactivityExcel; import com.epmet.service.StaffLoginLogService; 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.RestController; +import com.epmet.dto.result.yt.AccountActivityInfo; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** @@ -19,4 +40,115 @@ public class StaffLoginLogController { @Autowired private StaffLoginLogService staffLoginLogService; + + /** + * 返回市级账号登录总次数、区县级账号登录总次数、镇街级账号登录总次数、社区级账号登录总次数 + * + * @param formDTO + * @return + */ + @PostMapping("count-level") + public Result countLevel(@RequestBody LoginLogCountByLevelFormDTO formDTO) { + return new Result().ok(staffLoginLogService.countLevel(formDTO.getOrgId(), formDTO.getLevel(), formDTO.getStartDate(), formDTO.getEndDate())); + } + + /** + * 下级社区账号登录次数排名 + * + * @return + */ + @PostMapping("community-count") + public Result> communityCount(@RequestBody CommunityLoginFormDTO formDTO) { + return new Result>().ok(staffLoginLogService.pageCommunityCount(formDTO)); + } + + /** + * 柱状图:下级组织账号登录次数汇总 + * + * @param formDTO + * @return + */ + @PostMapping("sub-count") + public Result> querySubCount(@RequestBody LoginLogCountByLevelFormDTO formDTO) { + return new Result>().ok(staffLoginLogService.querySubCount(formDTO.getOrgId(), formDTO.getLevel(), formDTO.getStartDate(), formDTO.getEndDate())); + } + + /** + * 查看区县 + * + * @param formDTO + * @return + */ + @PostMapping("district-count") + public Result> districtCount(@RequestBody CommunityLoginFormDTO formDTO) { + return new Result>().ok(staffLoginLogService.pageDistrictCount(formDTO.getOrgId(), + formDTO.getLevel(), formDTO.getStartDate(), + formDTO.getEndDate(), formDTO.getIsPage(), + formDTO.getPageNo(), formDTO.getPageSize())); + } + + /** + * 查看街镇 + * + * @param formDTO + * @return + */ + @PostMapping("street-count") + public Result> streetCount(@RequestBody CommunityLoginFormDTO formDTO) { + return new Result>().ok(staffLoginLogService.streetCount(formDTO.getOrgId(), + formDTO.getStartDate(), + formDTO.getEndDate(), formDTO.getIsPage(), + formDTO.getPageNo(), formDTO.getPageSize())); + } + + /*** + * 获取当前agencyid下 下级组织活跃情况 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author qushutong + * @date 2023/4/6 13:41 + */ + @PostMapping("getAccountActivityInfo") + public Result> getAccountActivityInfo(@RequestBody CountActivityFormDTO formDTO) { + return new Result>().ok(staffLoginLogService.getAccountActivityInfo(formDTO)); + } + + /*** + * 获取活跃度总数 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author qushutong + * @date 2023/4/6 17:35 + */ + @PostMapping("getActivityTotal") + public Result getActivityTotal(@RequestBody CountActivityFormDTO formDTO) { + return new Result().ok(staffLoginLogService.getActivityTotal(formDTO)); + } + + + /*** + * 导出活跃 + * @param response + * @param tokenDto + * @param formDTO + * @return void + * @author qushutong + * @date 2023/4/6 18:04 + */ + @PostMapping("accountActivityInfo-export") + public void analysisExport(HttpServletResponse response, @LoginUser TokenDto tokenDto, @RequestBody CountActivityFormDTO formDTO) throws Exception { + formDTO.setIsPage(false); + PageData res = staffLoginLogService.getAccountActivityInfo(formDTO); + if (!CollectionUtils.isEmpty(res.getList())) { + if("1".equals(formDTO.getIsActivity())){ + List accountActivityExcels = ConvertUtils.sourceToTarget(res.getList(), AccountActivityExcel.class); + ExcelUtils.exportExcelToTarget(response, null, accountActivityExcels, AccountActivityInfo.class); + }else { + List accountActivityExcels = ConvertUtils.sourceToTarget(res.getList(), AccountInactivityExcel.class); + ExcelUtils.exportExcelToTarget(response, null, accountActivityExcels, AccountActivityInfo.class); + } + + } + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffLoginLogDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffLoginLogDao.java index c7c38f7bbd..0db1338752 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffLoginLogDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffLoginLogDao.java @@ -1,8 +1,16 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.yt.CountActivityFormDTO; +import com.epmet.dto.result.yt.ActivityTatalInfo; +import com.epmet.dto.result.yt.CommunityLoginResultDTO; +import com.epmet.dto.result.yt.AccountActivityInfo; import com.epmet.entity.StaffLoginLogEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; /** * 工作人员登录日志表 @@ -12,5 +20,56 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface StaffLoginLogDao extends BaseDao { - + + /** + * 各社区登录总次数 + * + * @param orgId + * @param startDate + * @param endDate + * @return + */ + List pageCommunityCount(@Param("orgId") String orgId, + @Param("startDate") Date startDate, + @Param("endDate") Date endDate); + + /** + * 柱状图:下级组织账号登录次数汇总 + * + * @param orgId + * @param startDate + * @param endDate + * @return + */ + List querySubCount(@Param("orgId") String orgId, + @Param("startDate") Date startDate, + @Param("endDate") Date endDate); + + /** + * 各区县登录总次数 + * + * @param orgId + * @param startDate + * @param endDate + * @return + */ + List pageDistrictCount(@Param("orgId") String orgId, + @Param("startDate") Date startDate, + @Param("endDate") Date endDate); + + List pageStreetCount(@Param("orgId") String orgId, + @Param("startDate") Date startDate, + @Param("endDate") Date endDate); + + /*** + * 获取登陆情况 + * @param formDTO + * @return com.epmet.dto.result.yt.AccountActivityInfo + * @author qushutong + * @date 2023/4/6 13:47 + */ + List selectListActivityInfo(CountActivityFormDTO formDTO); + + + ActivityTatalInfo selectOneActivityTotal(CountActivityFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/AccountActivityExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/AccountActivityExcel.java new file mode 100644 index 0000000000..4c7d6bd6f5 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/AccountActivityExcel.java @@ -0,0 +1,45 @@ +package com.epmet.excel.yt; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + + +/** + * @author: qushutong + * @Date: 2023/4/6 13:33 + * @Description: 账户活跃情况 + */ +@Data +public class AccountActivityExcel implements Serializable { + private static final long serialVersionUID = -918630886413844674L; + + /** + * 组织名称 + */ + @Excel(name = "组织名称") + private String agencyName = ""; + + /** + * 登陆次数 + */ + @Excel(name = "登陆次数") + private String loginCount = ""; + + /** + * 活跃账号数 + */ + @Excel(name = "活跃账号数") + private String accountActivityCount = ""; + + + /** + * 总账号数 + */ + @Excel(name = "总账号数") + private String accountCount = ""; + + + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/AccountInactivityExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/AccountInactivityExcel.java new file mode 100644 index 0000000000..6635ab63c9 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/yt/AccountInactivityExcel.java @@ -0,0 +1,28 @@ +package com.epmet.excel.yt; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + + +/** + * @author: qushutong + * @Date: 2023/4/6 13:33 + * @Description: 账户不活跃情况 + */ +@Data +public class AccountInactivityExcel implements Serializable { + private static final long serialVersionUID = -918630886413844674L; + + /** + * 组织名称 + */ + @Excel(name = "组织名称") + private String agencyName = ""; + + + + + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 37dbd8d699..d80ec62617 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -18,7 +18,6 @@ package com.epmet.service; 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.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; @@ -356,5 +355,12 @@ public interface CustomerAgencyService extends BaseService **/ Result> getCurrentUserCommunityInfo(TokenDto tokenDTO); + /** + * 返回组织的orgIdPath:包含自身 + * + * @param orgId + * @return + */ + String getOrgIdPath(String orgId); List getAgencyCountList(String agencyId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffLoginLogService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffLoginLogService.java index 4594c9cedd..5d39463647 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffLoginLogService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffLoginLogService.java @@ -1,6 +1,13 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.yt.CommunityLoginFormDTO; +import com.epmet.dto.form.yt.CountActivityFormDTO; +import com.epmet.dto.result.yt.ActivityTatalInfo; +import com.epmet.dto.result.yt.CommunityLoginResultDTO; +import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO; +import com.epmet.dto.result.yt.AccountActivityInfo; import com.epmet.entity.StaffLoginLogEntity; import java.util.Date; @@ -14,9 +21,77 @@ import java.util.Date; public interface StaffLoginLogService extends BaseService { /** * 登录,插入记录 + * * @param staffId * @param loginTime */ void saveLog(String staffId, Date loginTime); + /** + * 返回市级账号登录总次数、区县级账号登录总次数、镇街级账号登录总次数、社区级账号登录总次数 + * + * @param orgId 为空时,默认当前登录用户所属组织id + * @param level + * @param startDate yyyy-MM-dd + * @param endDate yyyy-MM-dd + * @return + */ + LoginLogCountByLevelResultDTO countLevel(String orgId, String level, Date startDate, Date endDate); + + /** + * 下级社区账号登录次数排名 + * + * @param formDTO + * @return + */ + PageData pageCommunityCount(CommunityLoginFormDTO formDTO); + + /** + * 柱状图:下级组织账号登录次数汇总 + * + * @param orgId + * @param level + * @param startDate + * @param endDate + * @return + */ + PageData querySubCount(String orgId, String level, Date startDate, Date endDate); + + /** + * 查看区县 + * + * @param orgId + * @param level + * @param startDate + * @param endDate + * @param isPage + * @param pageNo + * @param pageSize + * @return + */ + PageData pageDistrictCount(String orgId, String level, Date startDate, Date endDate, Boolean isPage, Integer pageNo, Integer pageSize); + + /** + * 查看街镇 + * + * @param orgId + * @param startDate + * @param endDate + * @param isPage + * @param pageNo + * @param pageSize + * @return + */ + PageData streetCount(String orgId, Date startDate, Date endDate, Boolean isPage, Integer pageNo, Integer pageSize); + + /*** + * 获取登陆情况 + * @param formDTO + * @return com.epmet.dto.result.yt.AccountActivityInfo + * @author qushutong + * @date 2023/4/6 13:47 + */ + PageData getAccountActivityInfo(CountActivityFormDTO formDTO); + + ActivityTatalInfo getActivityTotal(CountActivityFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index e52a6ddf6a..67f97aeb0c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -1607,6 +1607,23 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl>().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); + } @Override public List getAgencyCountList(String agencyId) { diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java index 52bd7a38f1..85e498a6c3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java @@ -1,25 +1,39 @@ 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.page.PageData; 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.form.yt.CommunityLoginFormDTO; +import com.epmet.dto.form.yt.CountActivityFormDTO; +import com.epmet.dto.result.yt.ActivityTatalInfo; +import com.epmet.dto.result.yt.CommunityLoginResultDTO; +import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO; +import com.epmet.dto.result.yt.AccountActivityInfo; import com.epmet.entity.StaffLoginLogEntity; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.CustomerAgencyService; import com.epmet.service.StaffLoginLogService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.Date; +import java.util.List; /** * 工作人员登录日志表 @@ -69,7 +83,222 @@ public class StaffLoginLogServiceImpl extends BaseServiceImpl cityWrapper = new LambdaQueryWrapper<>(); + cityWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId) + .between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate); + resultDTO.setCityCount(baseDao.selectCount(cityWrapper)); + + // 市下面区县账号 + LambdaQueryWrapper 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 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 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(level)) { + resultDTO.setCityCount(NumConstant.ONE_NEG); + + //只展示本区县的登录情况 + LambdaQueryWrapper districtWrapper = new LambdaQueryWrapper<>(); + districtWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId) + .between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate); + resultDTO.setDistrictCount(baseDao.selectCount(districtWrapper)); + + // 区县下所有的街道 + LambdaQueryWrapper 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 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(level)) { + resultDTO.setCityCount(NumConstant.ONE_NEG); + resultDTO.setDistrictCount(NumConstant.ONE_NEG); + + // 只展示本街道的登录情况 + LambdaQueryWrapper streetWrapper = new LambdaQueryWrapper<>(); + streetWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId) + .between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate); + resultDTO.setStreetCount(baseDao.selectCount(streetWrapper)); + + + // 街道下所有社区 + LambdaQueryWrapper 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(level)) { + resultDTO.setCityCount(NumConstant.ONE_NEG); + resultDTO.setDistrictCount(NumConstant.ONE_NEG); + resultDTO.setStreetCount(NumConstant.ONE_NEG); + + // 只展示本社区的登录情况 + LambdaQueryWrapper communityWrapper = new LambdaQueryWrapper<>(); + communityWrapper.eq(StaffLoginLogEntity::getAgencyId, orgId) + .between(null != startDate && null != endDate, StaffLoginLogEntity::getLoginTime, startDate, endDate); + resultDTO.setCommunityCount(baseDao.selectCount(communityWrapper)); + } + return resultDTO; + } + + @Override + public PageData getAccountActivityInfo(CountActivityFormDTO formDTO) { + List accountActivityInfos = baseDao.selectListActivityInfo(formDTO); + int total = CollectionUtils.isEmpty(accountActivityInfos) ? NumConstant.ZERO : accountActivityInfos.size(); + return new PageData<>(accountActivityInfos, total); + } + + @Override + public ActivityTatalInfo getActivityTotal(CountActivityFormDTO formDTO) { + return baseDao.selectOneActivityTotal(formDTO); + } + + /** + * 下级社区账号登录次数排名 + * + * @param formDTO + * @return + */ + @Override + public PageData pageCommunityCount(CommunityLoginFormDTO formDTO) { + if (StringUtils.isBlank(formDTO.getOrgId())) { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId()); + formDTO.setOrgId(staffInfoCacheResult.getAgencyId()); + formDTO.setLevel(staffInfoCacheResult.getLevel()); + } + if (formDTO.getIsPage()) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + List list = baseDao.pageCommunityCount(formDTO.getOrgId(), formDTO.getStartDate(), formDTO.getEndDate()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal(), formDTO.getPageSize()); + } + // 不分页 + List list = baseDao.pageCommunityCount(formDTO.getOrgId(), formDTO.getStartDate(), formDTO.getEndDate()); + int total = CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size(); + return new PageData<>(list, total, total); + } + + + /** + * 柱状图:下级组织账号登录次数汇总 + * + * @param orgId + * @param level + * @param startDate + * @param endDate + * @return + */ + @Override + public PageData querySubCount(String orgId, String level, Date startDate, Date endDate) { + if (StringUtils.isBlank(orgId)) { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId()); + orgId = staffInfoCacheResult.getAgencyId(); + } + List list = baseDao.querySubCount(orgId, startDate, endDate); + int total = CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size(); + return new PageData(list, total, total); + } + /** + * 查看区县 + * + * @param orgId + * @param level + * @param startDate + * @param endDate + * @param isPage + * @param pageNo + * @param pageSize + * @return 返回agencyId,agencyName,count + */ + @Override + public PageData pageDistrictCount(String orgId, String level, Date startDate, Date endDate, Boolean isPage, Integer pageNo, Integer pageSize) { + if (StringUtils.isBlank(orgId)) { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId()); + orgId = staffInfoCacheResult.getAgencyId(); + } + if (isPage) { + PageHelper.startPage(pageNo, pageSize); + List list = baseDao.pageDistrictCount(orgId, startDate, endDate); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal(), pageSize); + } + // 不分页 + List list = baseDao.pageDistrictCount(orgId, startDate, endDate); + int total = CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size(); + return new PageData<>(list, total, total); + } + /** + * 查看街镇 + * + * @param orgId + * @param startDate + * @param endDate + * @param isPage + * @param pageNo + * @param pageSize + * @return + */ + @Override + public PageData streetCount(String orgId, Date startDate, Date endDate, Boolean isPage, Integer pageNo, Integer pageSize) { + if (StringUtils.isBlank(orgId)) { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId()); + orgId = staffInfoCacheResult.getAgencyId(); + } + if (isPage) { + PageHelper.startPage(pageNo, pageSize); + List list = baseDao.pageStreetCount(orgId, startDate, endDate); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal(), pageSize); + } + // 不分页 + List list = baseDao.pageStreetCount(orgId, startDate, endDate); + int total = CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size(); + return new PageData<>(list, total, total); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffLoginLogDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffLoginLogDao.xml index bba55ac5d9..6ed487ad44 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffLoginLogDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffLoginLogDao.xml @@ -22,5 +22,170 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml index bd7853c4e0..d7e0d5ff39 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml @@ -28,6 +28,7 @@ and e.GRID_ID=#{orgId} + and e.DEL_FLAG = '0' and CUSTOMER_ID = #{customerId} and HAPPEN_TIME >= #{queryStartTime} and HAPPEN_TIME #{queryEndTime} @@ -81,7 +82,8 @@ select date_format(e.HAPPEN_TIME, '%Y-%m') monthName from ic_event e - e.HAPPEN_TIME >= date_format(#{queryStartTime}, '%Y-%m') + e.DEL_FLAG = '0' + and e.HAPPEN_TIME >= date_format(#{queryStartTime}, '%Y-%m') and e.HAPPEN_TIME date_format(#{queryEndTime}, '%Y-%m') and e.GRID_ID =#{orgId}