diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java index 196aa19dcf..920fc14e14 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java @@ -9,5 +9,6 @@ public interface DataSourceConstant { String GOV_VOICE = "govVoice"; String OPER_CRM = "operCrm"; String RESI_GROUP = "resiGroup"; + String EPMET_USER = "epmetuser"; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/AgencySubDeptTreeDto.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/AgencySubDeptTreeDto.java new file mode 100644 index 0000000000..c854859bc6 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/AgencySubDeptTreeDto.java @@ -0,0 +1,61 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @ClassName AgencySubDeptTreeDto + * @Auth wangc + * @Date 2020-06-18 16:06 + */ +@Data +public class AgencySubDeptTreeDto implements Serializable { + private static final long serialVersionUID = -8179035699122094719L; + /** + * 机构Id + * */ + private String agencyId; + + /** + * 机构名称 + * */ + private String agencyName; + + /** + * 直属网格Id + * */ + List gridIds; + + /** + * 直属部门Id + * */ + List deptIds; + + /** + * 客户Id + * */ + String customerId; + + /** + * 父级机关Id,当为最顶层是pid为0 + * */ + String pid; + + /** + * 级别 + * 社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province + * */ + String level; + + /** + * 下级机关集合 + * */ + List subAgencies; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/CommonTotalAndIncCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/CommonTotalAndIncCountResultDTO.java new file mode 100644 index 0000000000..7296a1b236 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/CommonTotalAndIncCountResultDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @ClassName CommonTotalAndIncCountResultDTO + * @Auth wangc + * @Date 2020-06-18 17:28 + */ +@Data +public class CommonTotalAndIncCountResultDTO implements Serializable { + private static final long serialVersionUID = -5215017168317858826L; + + private Integer total; + + private Integer incr; +} diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 93bf1c3703..74787dff5d 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -141,13 +141,19 @@ epmet_resi_group_user EpmEt-db-UsEr + + + + epmet_user_user + EpmEt-db-UsEr + 0 192.168.1.130 6379 123456 - false + true 122.152.200.70:8848 fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java index 6efd8bf7da..2d0cd77530 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java @@ -2,6 +2,7 @@ package com.epmet.controller; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.AgencySubDeptTreeDto; import com.epmet.dto.AgencySubTreeDto; import com.epmet.service.StatsDimService; import com.epmet.service.stats.*; @@ -237,4 +238,29 @@ public class DimController { public List topAgency() { return dimAgencyService.getTopAgency(); } + + /** + * @Description 所有机构 - 带部门 + * @param + * @return + * @author wangc + * @date 2020.06.18 10:34 + **/ + @GetMapping("allagencydept") + public List allAgencyDept(){ + return dimAgencyService.getAllAgencyWithDept(); + } + + /** + * @Description 顶级机构 - 带部门 + * @param + * @return + * @author wangc + * @date 2020.06.18 10:34 + **/ + @GetMapping("topagencydept") + public List topAgencyDept(){ + return dimAgencyService.getTopAgencyWithDept(); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java index 958df384be..f4d1477562 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java @@ -19,6 +19,7 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.AgencySubDeptTreeDto; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.stats.DimAgencyDTO; import com.epmet.entity.stats.DimAgencyEntity; @@ -81,4 +82,31 @@ public interface DimAgencyDao extends BaseDao { */ List getAgencyListByCustomerId(@Param("customerId") String customerId); + + /** + * @Description 带部门 获取所有机关 + * @param + * @return List + * @author wangc + * @date 2020.06.18 09:26 + **/ + List selectAllAgencyWithDept(); + + /** + * @Description 带部门 根据PID获取下级机关 + * @param pid + * @return List + * @author wangc + * @date 2020.06.18 09:26 + **/ + List selectSubAgencyWithDeptByPid(@Param("pid")String pid); + + /** + * @Description 带部门 获取顶层级机关机关 + * @param + * @return List + * @author wangc + * @date 2020.06.18 09:26 + **/ + List selectTopAgencyWithDept(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java index 88cf420e8a..d96d1787e1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java @@ -1,6 +1,12 @@ package com.epmet.dao.user; +import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; +import java.util.Set; /** * 用户Dao EpmetUser @@ -11,4 +17,84 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface UserDao { + /** + * @Description 查询注册用户的总量与增量 + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + CommonTotalAndIncCountResultDTO selectResiTotalAndIncrByLevel(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate")Date targetDate); + + /** + * @Description 查询党员的总量与增量 + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + CommonTotalAndIncCountResultDTO selectPartyTotalAndIncr(@Param("userIds") List userIds, @Param("incrUserIds") List incrUserIds, @Param("targetDate") Date targetDate); + + /** + * @Description 查询热心居民的总量与增量 + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + CommonTotalAndIncCountResultDTO selectWarmTotalAndIncr(@Param("userIds") List userIds, @Param("incrUserIds") List incrUserIds, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + + /** + * @Description 查询指定网格范围下单位时间内新增的注册用户Id + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + List selectIncrUserIds(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + + /** + * @Description 查询指定网格范围下截至指定位时间累计的注册用户Id + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + List selectTotalUserIds(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + + /** + * @Description 查询指定时间范围内网格新增的注册/参与用户Id + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + List selectIncrUserIdsWithinTimeRange(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("startDate")Date startDate,@Param("endDate")Date endDate); + + /** + * @Description 查询指定时间范围内注册/参与用户增量 + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + Integer selectResiIncrWithinTimeRange(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("startDate")Date startDate,@Param("endDate")Date endDate); + + /** + * @Description 查询指定时间范围内党员的增量 + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + Integer selectPartyIncrWithinTimeRange(@Param("incrUserIds")List incrUserIds,@Param("startDate")Date startDate,@Param("endDate")Date endDate); + + /** + * @Description 查询指定时间范围内热心居民的增量 + * @param + * @return + * @author wangc + * @date 2020.06.18 18:50 + **/ + Integer selectWarmIncrWithinTimeRange(@Param("incrUserIds")List incrUserIds,@Param("gridIds") Set gridIds,@Param("startDate")Date startDate,@Param("endDate")Date endDate); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java index 17b8076777..fe9fbd9765 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java @@ -19,6 +19,7 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.AgencySubDeptTreeDto; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.stats.DimAgencyDTO; import com.epmet.entity.org.CustomerAgencyEntity; @@ -138,4 +139,24 @@ public interface DimAgencyService extends BaseService { */ List getAgencyListByCustomerId(String customerId); + + + /** + * @Description 带部门 查询所有机关以及它下级机关的信息 + * @param + * @return List + * @author wangc + * @date 2020.06.18 09:45 + **/ + List getAllAgencyWithDept(); + + + /** + * @Description 带部门 查询顶级机关以及它下级机关的信息 + * @param + * @return List + * @author wangc + * @date 2020.06.18 09:45 + **/ + List getTopAgencyWithDept(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index af550d986c..0c86f00ef4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java @@ -29,6 +29,7 @@ import com.epmet.constant.RobotConstant; import com.epmet.constant.StatsSubject; import com.epmet.dao.stats.DimAgencyDao; import com.epmet.dao.stats.LastExecRecordDao; +import com.epmet.dto.AgencySubDeptTreeDto; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.stats.DimAgencyDTO; import com.epmet.entity.org.CustomerAgencyEntity; @@ -173,4 +174,31 @@ public class DimAgencyServiceImpl extends BaseServiceImpl + * @author wangc + * @date 2020.06.18 09:45 + **/ + @Override + public List getAllAgencyWithDept() { + return baseDao.selectAllAgencyWithDept(); + } + + + /** + * @Description 带部门 查询顶级机关以及它下级机关的信息 + * @param + * @return List + * @author wangc + * @date 2020.06.18 09:45 + **/ + @Override + public List getTopAgencyWithDept() { + return baseDao.selectTopAgencyWithDept(); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java index 71e2911e5b..3f20d2a9e7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java @@ -2,6 +2,7 @@ package com.epmet.service.user; import com.epmet.dto.AgencySubTreeDto; +import java.util.Date; import java.util.List; import java.util.Map; @@ -9,11 +10,19 @@ public interface UserService { /** * @Description 遍历所有机关(它的下级机关)统计注册用户和参与用户的数据,使用level控制 - * @param regOrPartiFlag - String - * @parma agencies - Map> + * @param topAgencies - List * @return * @author wangc * @date 2020.06.18 10:03 **/ - void traverseAgencyUser(String regOrPartiFlag,Map>agencies); + void traverseAgencyUser(List topAgencies, Date targetDate); + + /** + * @Description 遍历所有机关的直属网格统计注册用户参与用户的数据 + * @param agencies - List + * @return + * @author wangc + * @date 2020.06.18 10:03 + **/ + void traverseGridUser(List agencies, Date targetDate); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index 6737398a52..6ac8e6294b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -1,11 +1,22 @@ package com.epmet.service.user.impl; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.user.UserDao; import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO; import com.epmet.service.user.UserService; +import com.epmet.util.ModuleConstant; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; /** * @Description 直连epmet-user @@ -13,19 +24,204 @@ import java.util.Map; * @Auth wangc * @Date 2020-06-18 09:55 */ +@DataSource(DataSourceConstant.EPMET_USER) @Service public class UserServiceImpl implements UserService { + private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class); + + @Autowired + private UserDao userDao; + /** * @Description 遍历所有机关(它的下级机关)统计注册用户和参与用户的数据,使用level控制 - * @param regOrPartiFlag - String - * @parma agencies - Map> + * @param topAgencies - List + * @return + * @author wangc + * @date 2020.06.18 10:03 + **/ + @Override + public void traverseAgencyUser(List topAgencies, Date targetDate) { + if(null == topAgencies || topAgencies.size() == NumConstant.ZERO){ + logger.warn("没有相应的机关集合"); + return ; + } + //自上向下检索 + //Map> agencyMap = agencies.stream().collect(Collectors.groupingBy(AgencySubTreeDto::getAgencyId)); + Map> subGridOfAgency = new HashMap<>(); + topAgencies.forEach(agency -> { + initAgencyGridMap(agency,subGridOfAgency); + }); + + //对每一个机关进行数据统计 + if(subGridOfAgency.size() > NumConstant.ZERO){ + subGridOfAgency.forEach((k,v) -> { + queryUserData(v,targetDate); + }); + } + + } + + /** + * @Description 遍历所有机关的直属网格统计注册用户参与用户的数据 + * @param agencies - List * @return * @author wangc * @date 2020.06.18 10:03 **/ @Override - public void traverseAgencyUser(String regOrPartiFlag, Map> agencies) { + public void traverseGridUser(List agencies, Date targetDate) { + if(null == agencies || agencies.size() == NumConstant.ZERO){ + logger.warn("没有相应的机关集合"); + return ; + } + //自上向下检索 + Map> agencyMap = agencies.stream().collect(Collectors.groupingBy(AgencySubTreeDto::getAgencyId)); + if(null != agencyMap && agencyMap.size() > NumConstant.ZERO){ + agencyMap.forEach((k,v) -> { + if(null != v && v.size() > NumConstant.ZERO){ + queryUserData(new HashSet<>(v.get(NumConstant.ZERO).getGridIds()),targetDate); + } + }); + } + } + + /** + * @Description 初始化机关-所有下级网格Map + * @param agency - AgencySubTreeDto + * @param subGridOfAgency - Map> + * @return + * @author wangc + * @date 2020.06.18 15:54 + **/ + void initAgencyGridMap(AgencySubTreeDto agency, Map> subGridOfAgency){ + //向map中放入数据 + if(subGridOfAgency.containsKey(agency.getAgencyId())){ + //包含key + Set grids = subGridOfAgency.get(agency.getAgencyId()); + if(null == grids){ + grids = new HashSet<>(); + subGridOfAgency.put(agency.getAgencyId(),grids); + } + if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){ + grids.addAll(agency.getGridIds()); + } + }else{ + //不包含key + Set grids = new HashSet<>(agency.getGridIds()); + subGridOfAgency.put(agency.getAgencyId(),grids); + } + + //定义递归出口 + if(StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY,agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO){ + return ; + } + + //定义递归入口 + agency.getSubAgencies().forEach(obj -> { + initAgencyGridMap(obj,subGridOfAgency); + }); + } + + /** + * @Description 执行查询用户数据统计的逻辑 + * @param gridIds - 机关下所有网格集合/机关下直属网格集合 + * @param targetDate + * @return + * @author wangc + * @date 2020.06.19 10:01 + **/ + void queryUserData(Set gridIds,Date targetDate){ + //默认查询注册用户 + + //1.计算机关下注册用户一个时间单位内的累计与增长 + CommonTotalAndIncCountResultDTO regData = + userDao.selectResiTotalAndIncrByLevel(ModuleConstant.REG_OR_PARTI_FLAG_REG,gridIds,targetDate); + //2.查询注册用户的Id列表 + List incrRegUsers = + userDao.selectIncrUserIds(ModuleConstant.REG_OR_PARTI_FLAG_REG,gridIds,targetDate); + List totalRegUsers = + userDao.selectTotalUserIds(ModuleConstant.REG_OR_PARTI_FLAG_REG,gridIds,targetDate); + //3.查询机关下一个时间单位内热心居民的累计与增量(注册用户) + CommonTotalAndIncCountResultDTO warmRegData = + userDao.selectWarmTotalAndIncr(totalRegUsers,incrRegUsers,gridIds,targetDate); + //4.查询机关下一个时间单位内党员的累计与增量(注册用户) + CommonTotalAndIncCountResultDTO partyRegData = + userDao.selectPartyTotalAndIncr(totalRegUsers,incrRegUsers,targetDate); + + + //参与用户 + //1.计算机关下参与用户一个时间单位内的累计与增长 + CommonTotalAndIncCountResultDTO partiData = + userDao.selectResiTotalAndIncrByLevel(ModuleConstant.REG_OR_PARTI_FLAG_PARTI,gridIds,targetDate); + //2.查询参与用户的Id列表 + List incrPartiUsers = + userDao.selectIncrUserIds(ModuleConstant.REG_OR_PARTI_FLAG_PARTI,gridIds,targetDate); + List totalPartiUsers = + userDao.selectTotalUserIds(ModuleConstant.REG_OR_PARTI_FLAG_PARTI,gridIds,targetDate); + //3.查询机关下一个时间单位内热心居民的累计与增量(参与用户) + CommonTotalAndIncCountResultDTO warmPartiData = + userDao.selectWarmTotalAndIncr(totalPartiUsers,incrPartiUsers,gridIds,targetDate); + //4.查询机关下一个时间单位内党员的累计与增量(参与用户) + CommonTotalAndIncCountResultDTO partyPartiData = + userDao.selectPartyTotalAndIncr(totalPartiUsers,incrPartiUsers,targetDate); + + + Calendar calendar =Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.DATE, NumConstant.ONE_NEG); + Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate; + + calendar.setTime(targetDateCheck); + //如果目标日期是当月的最后一天 + if(calendar.get(Calendar.DATE) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH)){ + //求出这个月的第一天 + calendar.setTime(new Date()); + calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE); + calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); + calendar.set(Calendar.MINUTE, NumConstant.ZERO); + calendar.set(Calendar.SECOND, NumConstant.ZERO); + + //本月注册用户增长数 + Integer regIncrMonthly = userDao.selectResiIncrWithinTimeRange(ModuleConstant.REG_OR_PARTI_FLAG_REG,gridIds,calendar.getTime(),targetDateCheck); + //本月新增注册用户Id集合 + List incrRegIdsMonthly = userDao.selectIncrUserIdsWithinTimeRange(ModuleConstant.REG_OR_PARTI_FLAG_REG,gridIds,calendar.getTime(),targetDateCheck); + //本月新增党员数(注册用户) + Integer incrPartyOfRegMonthly = userDao.selectPartyIncrWithinTimeRange(incrRegIdsMonthly,calendar.getTime(),targetDateCheck); + //本月新增热心居民数(注册用户) + Integer incrWarmOfRegMonthly = userDao.selectWarmIncrWithinTimeRange(incrRegIdsMonthly,gridIds,calendar.getTime(),targetDateCheck); + + + //本月参与用户增长数 + Integer partiIncrMonthly = userDao.selectResiIncrWithinTimeRange(ModuleConstant.REG_OR_PARTI_FLAG_PARTI,gridIds,calendar.getTime(),targetDateCheck); + //本月新增参与用户Id集合 + List incrPartiIdsMonthly = userDao.selectIncrUserIdsWithinTimeRange(ModuleConstant.REG_OR_PARTI_FLAG_PARTI,gridIds,calendar.getTime(),targetDateCheck); + //本月新增党员数(参与用户) + Integer incrPartyOfPartiMonthly = userDao.selectPartyIncrWithinTimeRange(incrPartiIdsMonthly,calendar.getTime(),targetDateCheck); + //本月新增热心居民数(参与用户) + Integer incrWarmOfPartiMonthly = userDao.selectWarmIncrWithinTimeRange(incrPartiIdsMonthly,gridIds,calendar.getTime(),targetDateCheck); + + } + } + + public static void main(String[] args) { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + System.out.println(format.format(calendar.getTime())); + + + calendar.setTime(calendar.getTime()); + calendar.add(Calendar.DATE, -1); + System.out.println(calendar.getTime()); + System.out.println(format.format(calendar.getTime())); + System.out.println(format2.format(calendar.getTime())); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/DimIdGenerator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/DimIdGenerator.java index 9a2d5ce6e8..35e1f6d99b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/DimIdGenerator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/DimIdGenerator.java @@ -75,7 +75,6 @@ public class DimIdGenerator { public static void main(String[] args) { DimIdBean dimIdBean = getDimIdBean(DateUtils.stringToDate("2020-06-14",DateUtils.DATE_PATTERN)); System.out.println(dimIdBean); - } @Data diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java new file mode 100644 index 0000000000..1ef0b26a51 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/ModuleConstant.java @@ -0,0 +1,19 @@ +package com.epmet.util; + +public interface ModuleConstant { + + /** + * 注册用户标识 + * */ + String REG_OR_PARTI_FLAG_REG = "reg"; + + /** + * 参与用户标识 + * */ + String REG_OR_PARTI_FLAG_PARTI = "parti"; + + /** + * 机关级别-社区 + * */ + String AGENCY_LEVEL_COMMUNITY = "community"; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml index 3bed21f9fe..ad6caadfa5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml @@ -150,6 +150,11 @@ dynamic: url: @datasource.druid.group.url@ username: @datasource.druid.group.username@ password: @datasource.druid.group.password@ + epmetuser: + driver-class-name: com.mysql.cj.jdbc.Driver + url: @datasource.druid.user.url@ + username: @datasource.druid.user.username@ + password: @datasource.druid.user.password@ thread: # 线程池配置 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml index 4c9d2a1dbb..d139aff3ee 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml @@ -115,4 +115,105 @@ AND CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml new file mode 100644 index 0000000000..91dc279ec1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml @@ -0,0 +1,323 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +