diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridDailyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridDailyDTO.java index a0d86d6164..2be14c087f 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridDailyDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridDailyDTO.java @@ -19,6 +19,8 @@ package com.epmet.dto.stats.user; import java.io.Serializable; import java.util.Date; + +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.math.BigDecimal; @@ -150,4 +152,16 @@ public class FactParticipationUserGridDailyDTO implements Serializable { */ private String delFlag; + public FactParticipationUserGridDailyDTO() { + this.regTotal = NumConstant.ZERO; + this.resiTotal = NumConstant.ZERO; + this.warmHeartedTotal = NumConstant.ZERO; + this.partymemberTotal = NumConstant.ZERO; + this.regIncr = NumConstant.ZERO; + this.warmIncr = NumConstant.ZERO; + this.partymemberIncr = NumConstant.ZERO; + this.resiProportion = NumConstant.ZERO_DECIMAL; + this.partymemberProportion = NumConstant.ZERO_DECIMAL; + this.warmHeartedProportion = NumConstant.ZERO_DECIMAL; + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridMonthlyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridMonthlyDTO.java index 15221181a8..be34873cf6 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridMonthlyDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactParticipationUserGridMonthlyDTO.java @@ -19,6 +19,8 @@ package com.epmet.dto.stats.user; import java.io.Serializable; import java.util.Date; + +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.math.BigDecimal; @@ -149,4 +151,16 @@ public class FactParticipationUserGridMonthlyDTO implements Serializable { */ private String delFlag; + public FactParticipationUserGridMonthlyDTO() { + this.regTotal = NumConstant.ZERO; + this.resiTotal = NumConstant.ZERO; + this.warmHeartedTotal = NumConstant.ZERO; + this.partymemberTotal = NumConstant.ZERO; + this.regIncr = NumConstant.ZERO; + this.warmIncr = NumConstant.ZERO; + this.partymemberIncr = NumConstant.ZERO; + this.partymemberProportion = NumConstant.ZERO_DECIMAL; + this.resiProportion = NumConstant.ZERO_DECIMAL; + this.warmHeartedProportion = NumConstant.ZERO_DECIMAL; + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridDailyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridDailyDTO.java index cf2d64b687..ea99e123f8 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridDailyDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridDailyDTO.java @@ -19,6 +19,8 @@ package com.epmet.dto.stats.user; import java.io.Serializable; import java.util.Date; + +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.math.BigDecimal; @@ -149,4 +151,16 @@ public class FactRegUserGridDailyDTO implements Serializable { */ private String delFlag; + public FactRegUserGridDailyDTO() { + this.regTotal = NumConstant.ZERO; + this.resiTotal = NumConstant.ZERO; + this.warmHeartedTotal = NumConstant.ZERO; + this.partymemberTotal = NumConstant.ZERO; + this.regIncr = NumConstant.ZERO; + this.warmIncr = NumConstant.ZERO; + this.partymemberIncr = NumConstant.ZERO; + this.resiProportion = NumConstant.ZERO_DECIMAL; + this.partymemberProportion = NumConstant.ZERO_DECIMAL; + this.warmHeartedProportion = NumConstant.ZERO_DECIMAL; + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridMonthlyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridMonthlyDTO.java index 51308b4d4c..4060d75e7f 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridMonthlyDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/FactRegUserGridMonthlyDTO.java @@ -19,6 +19,8 @@ package com.epmet.dto.stats.user; import java.io.Serializable; import java.util.Date; + +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.math.BigDecimal; @@ -149,4 +151,16 @@ public class FactRegUserGridMonthlyDTO implements Serializable { */ private String delFlag; + public FactRegUserGridMonthlyDTO() { + this.regTotal = NumConstant.ZERO; + this.resiTotal = NumConstant.ZERO; + this.warmHeartedTotal = NumConstant.ZERO; + this.partymemberTotal = NumConstant.ZERO; + this.regIncr = NumConstant.ZERO; + this.warmIncr = NumConstant.ZERO; + this.partymemberIncr = NumConstant.ZERO; + this.warmHeartedProportion = NumConstant.ZERO_DECIMAL; + this.resiProportion = NumConstant.ZERO_DECIMAL; + this.partymemberProportion = NumConstant.ZERO_DECIMAL; + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/result/UserStatisticalData.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/result/UserStatisticalData.java index 40315afc0c..22e6955a83 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/result/UserStatisticalData.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/user/result/UserStatisticalData.java @@ -5,6 +5,7 @@ import com.epmet.dto.stats.user.*; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; /** @@ -71,4 +72,15 @@ public class UserStatisticalData implements Serializable { * yyyyMM */ private String monthId; + + public UserStatisticalData() { + this.partiAgencyDailyList = new ArrayList<>(); + this.partiGridDailyList = new ArrayList<>(); + this.partiAgencyMonthlyList = new ArrayList<>(); + this.partiGridMonthlyList = new ArrayList<>(); + this.regAgencyDailyList = new ArrayList<>(); + this.regGridDailyList = new ArrayList<>(); + this.regAgencyMonthlyList = new ArrayList<>(); + this.regGridMonthlyList = new ArrayList<>(); + } } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrAndTotalUserIdsResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrAndTotalUserIdsResultDTO.java new file mode 100644 index 0000000000..03df830d89 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrAndTotalUserIdsResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/7/27 10:41 上午 + * @DESC + */ +@Data +public class IncrAndTotalUserIdsResultDTO implements Serializable { + + private static final long serialVersionUID = 9116867002773352209L; + + private String gridId; + + private List userIds; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrWithinTimeRangeResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrWithinTimeRangeResultDTO.java new file mode 100644 index 0000000000..e922a0e3a6 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrWithinTimeRangeResultDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/7/28 10:58 上午 + * @DESC 查询指定时间范围内注册/参与用户增量 + */ +@Data +public class IncrWithinTimeRangeResultDTO implements Serializable { + + private static final long serialVersionUID = 6199087464367184830L; + + private String gridId; + + private Integer userCount; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/PartyTotalAndIncrResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/PartyTotalAndIncrResultDTO.java new file mode 100644 index 0000000000..e48cdda28c --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/PartyTotalAndIncrResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/7/27 4:53 下午 + * @DESC + */ +@Data +public class PartyTotalAndIncrResultDTO implements Serializable { + + private static final long serialVersionUID = 6546408164027047797L; + + private String gridId; + + private Integer incr; + + private Integer total; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalAndIncrResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalAndIncrResultDTO.java new file mode 100644 index 0000000000..d3bf207013 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalAndIncrResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/7/27 10:14 上午 + * @DESC + */ +@Data +public class TotalAndIncrResultDTO implements Serializable { + + private static final long serialVersionUID = -3184476610188193106L; + + private Integer total = 0; + + private Integer incr = 0; + + private String gridId; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalUserIdsResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalUserIdsResultDTO.java new file mode 100644 index 0000000000..1536055246 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalUserIdsResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/7/27 10:57 上午 + * @DESC + */ +@Data +public class TotalUserIdsResultDTO implements Serializable { + + private static final long serialVersionUID = 8236061658552220549L; + + private String gridId; + + private List userIds; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/WarmTotalAndIncrResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/WarmTotalAndIncrResultDTO.java new file mode 100644 index 0000000000..184d564447 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/WarmTotalAndIncrResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/7/27 1:30 下午 + * @DESC + */ +@Data +public class WarmTotalAndIncrResultDTO implements Serializable { + + private static final long serialVersionUID = -4864864583111279861L; + + private String gridId; + + private Integer total; + + private Integer incr; +} 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 3d63f88ce5..2149e8584d 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 @@ -5,11 +5,7 @@ import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO; import com.epmet.dto.extract.result.UserPartyResultDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.stats.form.GmUploadEventFormDTO; -import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO; -import com.epmet.dto.user.result.StaffRoleInfoDTO; -import com.epmet.dto.user.result.CustomerStaffDTO; -import com.epmet.dto.user.result.StaffPatrolRecordResult; -import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO; +import com.epmet.dto.user.result.*; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,6 +32,16 @@ public interface UserDao { **/ CommonTotalAndIncCountResultDTO selectResiTotalAndIncrByLevel(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + /** + * @Description 查询注册用户的总量与增量【新方法】 + * @Param regOrPartiFlag + * @Param gridIds + * @Param targetDate + * @author zxc + * @date 2021/7/27 10:20 上午 + */ + List selectResiTotalAndIncrByGridIds(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate,@Param("startDate")Date startDate); + /** * @param * @return @@ -45,6 +51,15 @@ public interface UserDao { **/ CommonTotalAndIncCountResultDTO selectPartyTotalAndIncr(@Param("userIds") List userIds, @Param("incrUserIds") List incrUserIds, @Param("targetDate") Date targetDate); + /** + * @Description 查询党员的总量与增量【新方法】 + * @Param targetDate + * @Param regOrPartiFlag + * @author zxc + * @date 2021/7/27 5:08 下午 + */ + List selectPartyTotalAndIncrNew(@Param("targetDate") Date targetDate,@Param("regOrPartiFlag") String regOrPartiFlag,@Param("startDate") Date startDate); + /** * @param * @return @@ -54,6 +69,18 @@ public interface UserDao { **/ CommonTotalAndIncCountResultDTO selectWarmTotalAndIncr(@Param("userIds") List userIds, @Param("incrUserIds") List incrUserIds, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + /** + * @Description 查询热心居民的总量与增量【新方法】 + * @Param userIds 总注册用户 + * @Param incrUserIds 增长注册用户 + * @Param gridIds 网格IDS + * @Param targetDate dateId eg:2021-07-27 + * @author zxc + * @date 2021/7/27 1:31 下午 + */ + List selectWarmTotalAndIncrByGrids(@Param("userIds") List userIds, @Param("incrUserIds") List incrUserIds, @Param("gridIds") Set gridIds, + @Param("targetDate") Date targetDate,@Param("startDate") Date startDate); + /** * @param * @return @@ -63,6 +90,17 @@ public interface UserDao { **/ List selectIncrUserIds(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + /** + * @Description 查询指定网格范围下单位时间内新增的注册用户Id【新方法】 + * @Param regOrPartiFlag + * @Param gridIds + * @Param targetDate + * @author zxc + * @date 2021/7/27 10:41 上午 + */ + List selectIncrUserIdsByGrids(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate, + @Param("selectType") String selectType,@Param("startDate")Date startDate); + /** * @param * @return @@ -90,6 +128,17 @@ public interface UserDao { **/ Integer selectResiIncrWithinTimeRange(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("startDate") Date startDate, @Param("endDate") Date endDate); + /** + * @Description 查询指定时间范围内注册/参与用户增量【新方法】 + * @Param regOrPartiFlag + * @Param gridIds + * @Param startDate + * @Param endDate + * @author zxc + * @date 2021/7/28 11:00 上午 + */ + List selectIncrWithinTimeRangeByGrids(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("startDate") Date startDate, @Param("endDate") Date endDate); + /** * @param * @return diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/UserStatisticalServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/UserStatisticalServiceImpl.java index f42f74645c..b483355a0a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/UserStatisticalServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/UserStatisticalServiceImpl.java @@ -3,8 +3,10 @@ package com.epmet.service.stats.user.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.dao.stats.user.*; +import com.epmet.dto.stats.user.*; import com.epmet.dto.stats.user.result.UserStatisticalData; import com.epmet.service.stats.user.UserStatisticalService; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + /** * @Description * @ClassName UserStatisticalServiceImpl @@ -61,55 +65,77 @@ public class UserStatisticalServiceImpl implements UserStatisticalService { if(null != data.getPartiAgencyDailyList() && data.getPartiAgencyDailyList().size() > NumConstant.ZERO){ participationUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); - participationUserAgencyDailyDao.insertBatch(data.getPartiAgencyDailyList()); + List> partition = ListUtils.partition(data.getPartiAgencyDailyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + participationUserAgencyDailyDao.insertBatch(p); + }); } if(null != data.getPartiAgencyMonthlyList() && data.getPartiAgencyMonthlyList().size() > NumConstant.ZERO){ participationUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); - participationUserAgencyMonthlyDao.insertBatch(data.getPartiAgencyMonthlyList()); - + List> partition = ListUtils.partition(data.getPartiAgencyMonthlyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + participationUserAgencyMonthlyDao.insertBatch(p); + }); } if(null != data.getPartiGridMonthlyList() && data.getPartiGridMonthlyList().size() > NumConstant.ZERO){ participationUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); - participationUserGridMonthlyDao.insertBatch(data.getPartiGridMonthlyList()); - + List> partition = ListUtils.partition(data.getPartiGridMonthlyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + participationUserGridMonthlyDao.insertBatch(p); + }); } if(null != data.getPartiGridDailyList() && data.getPartiGridDailyList().size() > NumConstant.ZERO){ participationUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); - participationUserGridDailyDao.insertBatch(data.getPartiGridDailyList()); + List> partition = ListUtils.partition(data.getPartiGridDailyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + participationUserGridDailyDao.insertBatch(p); + }); } if(null != data.getRegAgencyDailyList() && data.getRegAgencyDailyList().size() > NumConstant.ZERO){ regUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); - regUserAgencyDailyDao.insertBatch(data.getRegAgencyDailyList()); + List> partition = ListUtils.partition(data.getRegAgencyDailyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + regUserAgencyDailyDao.insertBatch(p); + }); } if(null != data.getRegAgencyMonthlyList() && data.getRegAgencyMonthlyList().size() > NumConstant.ZERO){ regUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); - regUserAgencyMonthlyDao.insertBatch(data.getRegAgencyMonthlyList()); + List> partition = ListUtils.partition(data.getRegAgencyMonthlyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + regUserAgencyMonthlyDao.insertBatch(p); + }); } if(null != data.getRegGridDailyList() && data.getRegGridDailyList().size() > NumConstant.ZERO){ regUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); - regUserGridDailyDao.insertBatch(data.getRegGridDailyList()); + List> partition = ListUtils.partition(data.getRegGridDailyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + regUserGridDailyDao.insertBatch(p); + }); } if(null != data.getRegGridMonthlyList() && data.getRegGridMonthlyList().size() > NumConstant.ZERO){ regUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); - regUserGridMonthlyDao.insertBatch(data.getRegGridMonthlyList()); + List> partition = ListUtils.partition(data.getRegGridMonthlyList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + regUserGridMonthlyDao.insertBatch(p); + }); } 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 6cfcc8e89e..5e593a1b79 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 @@ -17,11 +17,7 @@ import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.stats.user.*; import com.epmet.dto.stats.user.result.UserStatisticalData; -import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO; -import com.epmet.dto.user.result.StaffRoleInfoDTO; -import com.epmet.dto.user.result.CustomerStaffDTO; -import com.epmet.dto.user.result.StaffPatrolRecordResult; -import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO; +import com.epmet.dto.user.result.*; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; @@ -120,14 +116,16 @@ public class UserServiceImpl implements UserService { if(null != agencyMap && agencyMap.size() > NumConstant.ZERO){ agencyMap.forEach((agencyId,v) -> { if(null != v && v.size() > NumConstant.ZERO){ - queryUserData(ModuleConstant.DIM_BELONGING_GRID, + /*queryUserData(ModuleConstant.DIM_BELONGING_GRID, agencyId, // v.get(NumConstant.ZERO).getPid(), v.get(NumConstant.ZERO).getCustomerId(), new HashSet<>(v.get(NumConstant.ZERO).getGridIds()), targetDate, dataPacket, - timeDimension); + timeDimension);*/ + traverseGridUserDispose(agencyId,v.get(NumConstant.ZERO).getCustomerId(),new HashSet<>(v.get(NumConstant.ZERO).getGridIds()) + ,targetDate,dataPacket,timeDimension); } }); } @@ -709,6 +707,221 @@ public class UserServiceImpl implements UserService { } + /** + * @Description + * @Param agencyId 组织ID + * @Param customerId 客户ID + * @Param gridIds 网格IDS + * @Param targetDate dateId 日期 eg:2021-07-27 + * @Param dataPacket 数据包 + * @Param timeDimension 日期维度 + * @author zxc + * @date 2021/7/27 9:53 上午 + */ + void traverseGridUserDispose(String agencyId,String customerId, Set gridIds, Date targetDate, UserStatisticalData dataPacket, DimIdGenerator.DimIdBean timeDimension){ + if (CollectionUtils.isEmpty(gridIds)){ + return; + } + dataPacket.setCustomerId(customerId); + //计算百分比使用,保留小数点后两位 + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(NumConstant.SIX); + Calendar calendar =Calendar.getInstance(); + //求出T-1 + calendar.setTime(new Date()); + calendar.add(Calendar.DATE, NumConstant.ONE_NEG); + //指定日期 OR T-1 + calendar.setTime(calendar.getTime()); + //求出这个月的第一天 + 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); + //1.计算机关下注册用户一个时间单位内的累计与增长 + List regData = userDao.selectResiTotalAndIncrByGridIds(ModuleConstant.REG_OR_PARTI_FLAG_REG, gridIds, targetDate,calendar.getTime()); + //2.查询注册用户的Id列表 + // 增长 + List incrRegUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_REG, gridIds, targetDate,"incr",calendar.getTime()); + List incrUserIds = new ArrayList<>(); + if (!CollectionUtils.isEmpty(incrRegUsers)){ + incrRegUsers.forEach(i -> { + if (!CollectionUtils.isEmpty(i.getUserIds())){ + incrUserIds.addAll(i.getUserIds()); + } + }); + } + // 全部 + List totalRegUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_REG, gridIds, targetDate,"total",calendar.getTime()); + List totalUserIds = new ArrayList<>(); + if (!CollectionUtils.isEmpty(totalRegUsers)){ + totalRegUsers.forEach(t -> { + if (!CollectionUtils.isEmpty(t.getUserIds())){ + totalUserIds.addAll(t.getUserIds()); + } + }); + } + //3.查询机关下一个时间单位内热心居民的累计与增量(注册用户) + List warmRegData = userDao.selectWarmTotalAndIncrByGrids(totalUserIds, incrUserIds, gridIds, targetDate,calendar.getTime()); + //4.查询机关下一个时间单位内党员的累计与增量(注册用户) + List partyRegData = userDao.selectPartyTotalAndIncrNew(targetDate, ModuleConstant.REG_OR_PARTI_FLAG_REG,calendar.getTime()); + + //参与用户 + //1.计算机关下参与用户一个时间单位内的累计与增长 + List partiData = userDao.selectResiTotalAndIncrByGridIds(ModuleConstant.REG_OR_PARTI_FLAG_PARTI, gridIds, targetDate,calendar.getTime()); + //2.查询参与用户的Id列表[增长] + List incrPartiUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_PARTI, gridIds, targetDate, "incr",calendar.getTime()); + List incrPartiUserIds = new ArrayList<>(); + if (!CollectionUtils.isEmpty(incrPartiUsers)){ + incrPartiUsers.forEach(i -> { + if (!CollectionUtils.isEmpty(i.getUserIds())){ + incrPartiUserIds.addAll(i.getUserIds()); + } + }); + } + // 查询参与用户的Id列表[全部] + List totalPartiUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_PARTI, gridIds, targetDate, "total",calendar.getTime()); + List totalPartiUserIds = new ArrayList<>(); + if (!CollectionUtils.isEmpty(totalPartiUsers)){ + totalPartiUsers.forEach(t -> { + if (!CollectionUtils.isEmpty(t.getUserIds())){ + totalPartiUserIds.addAll(t.getUserIds()); + } + }); + } + //3.查询机关下一个时间单位内热心居民的累计与增量(参与用户) + List warmPartiData = userDao.selectWarmTotalAndIncrByGrids(totalPartiUserIds, incrPartiUserIds, gridIds, targetDate,calendar.getTime()); + //4.查询机关下一个时间单位内党员的累计与增量(参与用户) + List partyPartiData = userDao.selectPartyTotalAndIncrNew(targetDate, ModuleConstant.REG_OR_PARTI_FLAG_PARTI,calendar.getTime()); + + /** ==================== *开始组装数据* ==================== **/ + gridIds.forEach(gridId -> { + //注册用户网格级别 + FactRegUserGridDailyDTO regGridD = new FactRegUserGridDailyDTO(); + regGridD.setCustomerId(customerId); + regGridD.setGridId(gridId); + regGridD.setAgencyId(agencyId); + regGridD.setDateId(timeDimension.getDateId()); + regGridD.setWeekId(timeDimension.getWeekId()); + regGridD.setYearId(timeDimension.getYearId()); + regGridD.setCreatedBy(ModuleConstant.CREATED_BY_STATISTICAL_ROBOT); + regGridD.setResiProportion(new BigDecimal(NumConstant.ONE)); + //参与用户网格级别 + FactParticipationUserGridDailyDTO partiGridD = new FactParticipationUserGridDailyDTO(); + partiGridD.setCustomerId(customerId); + partiGridD.setGridId(gridId); + partiGridD.setAgencyId(agencyId); + partiGridD.setDateId(timeDimension.getDateId()); + partiGridD.setWeekId(timeDimension.getWeekId()); + partiGridD.setYearId(timeDimension.getYearId()); + partiGridD.setCreatedBy(ModuleConstant.CREATED_BY_STATISTICAL_ROBOT); + partiGridD.setResiProportion(new BigDecimal(NumConstant.ONE)); + FactRegUserGridMonthlyDTO regGridM = new FactRegUserGridMonthlyDTO(); + regGridM.setCustomerId(customerId); + regGridM.setGridId(gridId); + regGridM.setAgencyId(agencyId); + regGridM.setMonthId(timeDimension.getMonthId()); + regGridM.setQuarterId(timeDimension.getQuarterId()); + regGridM.setYearId(timeDimension.getYearId()); + regGridM.setPartymemberProportion(regGridD.getPartymemberProportion()); + regGridM.setWarmHeartedProportion(regGridD.getWarmHeartedProportion()); + regGridM.setCreatedBy(ModuleConstant.CREATED_BY_STATISTICAL_ROBOT); + regGridM.setResiProportion(new BigDecimal(NumConstant.ONE)); + FactParticipationUserGridMonthlyDTO partiGridM = new FactParticipationUserGridMonthlyDTO(); + partiGridM.setCustomerId(customerId); + partiGridM.setGridId(gridId); + partiGridM.setAgencyId(agencyId); + partiGridM.setMonthId(timeDimension.getMonthId()); + partiGridM.setQuarterId(timeDimension.getQuarterId()); + partiGridM.setYearId(timeDimension.getYearId()); + partiGridM.setCreatedBy(ModuleConstant.CREATED_BY_STATISTICAL_ROBOT); + partiGridM.setResiProportion(new BigDecimal(NumConstant.ONE)); + if (!CollectionUtils.isEmpty(regData)){ + for (TotalAndIncrResultDTO r : regData) { + if (gridId.equals(r.getGridId())){ + regGridD.setResiTotal(r.getTotal()); + regGridD.setRegTotal(r.getTotal()); + regGridD.setRegIncr(r.getIncr()); + regGridM.setRegTotal(r.getTotal()); + regGridM.setResiTotal(r.getTotal()); + regGridM.setRegIncr(r.getIncr()); + break; + } + } + } + if (!CollectionUtils.isEmpty(warmRegData)){ + for (WarmTotalAndIncrResultDTO w : warmRegData) { + if (gridId.equals(w.getGridId())){ + regGridD.setWarmHeartedTotal(w.getTotal()); + regGridD.setWarmIncr(w.getIncr()); + regGridM.setWarmHeartedTotal(w.getTotal()); + regGridM.setWarmIncr(w.getIncr()); + break; + } + } + } + if (!CollectionUtils.isEmpty(partiData)){ + for (TotalAndIncrResultDTO p : partiData) { + if (gridId.equals(p.getGridId())){ + partiGridD.setResiTotal(p.getTotal()); + partiGridD.setRegTotal(p.getTotal()); + partiGridD.setRegIncr(p.getIncr()); + partiGridM.setRegTotal(p.getTotal()); + partiGridM.setResiTotal(p.getTotal()); + partiGridM.setRegIncr(p.getIncr()); + break; + } + } + } + if (!CollectionUtils.isEmpty(partyRegData)){ + for (PartyTotalAndIncrResultDTO p : partyRegData) { + if (gridId.equals(p.getGridId())){ + regGridD.setPartymemberTotal(p.getTotal()); + regGridD.setPartymemberIncr(p.getIncr()); + regGridM.setPartymemberTotal(p.getTotal()); + regGridM.setPartymemberIncr(p.getIncr()); + regGridM.setPartymemberTotal(p.getTotal()); + regGridM.setPartymemberIncr(p.getIncr()); + break; + } + } + } + if (!CollectionUtils.isEmpty(warmPartiData)){ + for (WarmTotalAndIncrResultDTO w : warmPartiData) { + if (gridId.equals(w.getGridId())){ + partiGridD.setWarmHeartedTotal(w.getTotal()); + partiGridD.setWarmIncr(w.getIncr()); + partiGridM.setWarmHeartedTotal(w.getTotal()); + partiGridM.setWarmIncr(w.getIncr()); + break; + } + } + } + if (!CollectionUtils.isEmpty(partyPartiData)){ + for (PartyTotalAndIncrResultDTO p : partyPartiData) { + if (gridId.equals(p.getGridId())){ + partiGridD.setPartymemberTotal(p.getTotal()); + partiGridD.setPartymemberIncr(p.getIncr()); + partiGridM.setPartymemberTotal(p.getTotal()); + partiGridM.setPartymemberIncr(p.getIncr()); + break; + } + } + } + regGridD.setPartymemberProportion(regGridD.getRegTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)regGridD.getPartymemberTotal()/(float)regGridD.getRegTotal()))); + regGridD.setWarmHeartedProportion(regGridD.getRegTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)regGridD.getWarmHeartedTotal()/(float)regGridD.getRegTotal()))); + partiGridD.setPartymemberProportion(partiGridD.getPartymemberTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)partiGridD.getPartymemberTotal()/(float)partiGridD.getRegTotal() ))); + partiGridD.setWarmHeartedProportion(partiGridD.getPartymemberTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)partiGridD.getWarmHeartedTotal()/(float)partiGridD.getRegTotal() ))); + regGridM.setPartymemberProportion(regGridD.getPartymemberProportion()); + regGridM.setWarmHeartedProportion(regGridD.getWarmHeartedProportion()); + partiGridM.setPartymemberProportion(partiGridD.getPartymemberProportion()); + partiGridM.setWarmHeartedProportion(partiGridD.getWarmHeartedProportion()); + dataPacket.getRegGridDailyList().add(regGridD); + dataPacket.getPartiGridDailyList().add(partiGridD); + dataPacket.getRegGridMonthlyList().add(regGridM); + dataPacket.getPartiGridMonthlyList().add(partiGridM); + }); + + } /** * @return java.util.List 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 index d0fc049555..727b653266 100644 --- 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 @@ -627,6 +627,190 @@ AND DATE_FORMAT( r.ACTRUAL_END_TIME, '%Y%m%d' ) = #{dateId} + + + + + + + + + + + + + + + + + + + + + DELETE FROM