From 84460ddff035577170771b54262601db32692d09 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 26 Jul 2021 17:30:40 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=B0=8F=E7=BB=84=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E3=80=90=E7=BD=91=E6=A0=BC-=E6=97=A5=E3=80=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=EF=BC=8C=E6=8F=92=E5=85=A5=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/stats/FactGroupGridDailyDao.java | 2 +- .../stats/impl/FactGroupGridDailyServiceImpl.java | 14 +++++++++++--- .../mapper/stats/FactGroupGridDailyDao.xml | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java index 5dfd4bc79d..c468f3a27c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java @@ -48,7 +48,7 @@ public interface FactGroupGridDailyDao extends BaseDao * @param dateId * @author zxc */ - void deleteInsertDateId(@Param("dateId")String dateId,@Param("customerId")String customerId); + Integer deleteInsertDateId(@Param("dateId")String dateId,@Param("customerId")String customerId); /** * @Description 根据机关级别查询小组数据 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java index d59d82e1e0..f0c8d90832 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java @@ -32,10 +32,12 @@ import com.epmet.dto.stats.FactGroupGridDailyDTO; import com.epmet.entity.stats.FactGroupGridDailyEntity; import com.epmet.service.StatsGroupService; import com.epmet.service.stats.FactGroupGridDailyService; +import org.apache.commons.collections4.ListUtils; 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.Arrays; import java.util.List; @@ -114,12 +116,18 @@ public class FactGroupGridDailyServiceImpl extends BaseServiceImpl formDto,String customerId) { - if (formDto.size() == NumConstant.ZERO){ + if (CollectionUtils.isEmpty(formDto)){ return; } String dateId = formDto.get(NumConstant.ZERO).getDateId(); - baseDao.deleteInsertDateId(dateId,customerId); - baseDao.insertGroupGridDaily(formDto); + Integer delNum; + do { + delNum = baseDao.deleteInsertDateId(dateId,customerId); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); + List> partition = ListUtils.partition(formDto, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + baseDao.insertGroupGridDaily(p); + }); } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml index 7b4c669324..0f3e92b1d6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml @@ -74,6 +74,7 @@ WHERE date_id = #{dateId} AND customer_id = #{customerId} + limit 1000 From fc6e36d34df4781b6e512ad953baa69056e46368 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 27 Jul 2021 09:30:08 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/service/group/impl/GroupDataServiceImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java index a7a596ca10..9263313f48 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java @@ -64,11 +64,7 @@ public class GroupDataServiceImpl implements GroupDataService { formDTO.setCustomerId(customerId); formDTO.setDateId(dateId); List gridGroupTotalResultDTOS = groupDataDao.selectGridGroupTotal(formDTO); - if (gridGroupTotalResultDTOS.size() == NumConstant.ZERO){ - result.forEach(grid -> { - grid.setGroupTotal(NumConstant.ZERO); - }); - }else { + if (!CollectionUtils.isEmpty(gridGroupTotalResultDTOS)){ result.forEach(grid -> { gridGroupTotalResultDTOS.forEach(groupTotal -> { if (grid.getGridId().equals(groupTotal.getGridId())) { From 83e7dfc707c6cc78158c0d3c5b45893a87edfe0e Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 28 Jul 2021 16:05:38 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BC=98=E5=8C=96=F0=9F=99=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FactParticipationUserGridDailyDTO.java | 14 ++ .../FactParticipationUserGridMonthlyDTO.java | 14 ++ .../stats/user/FactRegUserGridDailyDTO.java | 14 ++ .../stats/user/FactRegUserGridMonthlyDTO.java | 14 ++ .../user/result/UserStatisticalData.java | 12 + .../result/IncrAndTotalUserIdsResultDTO.java | 21 ++ .../result/IncrWithinTimeRangeResultDTO.java | 20 ++ .../result/PartyTotalAndIncrResultDTO.java | 22 ++ .../user/result/TotalAndIncrResultDTO.java | 22 ++ .../user/result/TotalUserIdsResultDTO.java | 21 ++ .../result/WarmTotalAndIncrResultDTO.java | 22 ++ .../main/java/com/epmet/dao/user/UserDao.java | 59 ++++- .../user/impl/UserStatisticalServiceImpl.java | 46 +++- .../service/user/impl/UserServiceImpl.java | 227 +++++++++++++++++- .../main/resources/mapper/user/UserDao.xml | 184 ++++++++++++++ 15 files changed, 690 insertions(+), 22 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrAndTotalUserIdsResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/IncrWithinTimeRangeResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/PartyTotalAndIncrResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalAndIncrResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/TotalUserIdsResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/WarmTotalAndIncrResultDTO.java 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 From df12e5cc9e6ea9ed713b7dc9f3b43253ffe28f22 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 29 Jul 2021 11:06:16 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BC=98=E5=8C=96?= =?UTF-8?q?=F0=9F=99=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/IncrAndTotalUserIdsResultDTO.java | 5 + .../result/PartyTotalAndIncrResultDTO.java | 4 +- .../user/result/TotalAndIncrResultDTO.java | 13 +- .../result/WarmTotalAndIncrResultDTO.java | 17 ++- .../main/java/com/epmet/dao/user/UserDao.java | 32 +++-- .../service/user/impl/UserServiceImpl.java | 103 +++++++++----- .../java/com/epmet/util/ModuleConstant.java | 4 + .../main/resources/mapper/user/UserDao.xml | 132 ++++++++++++++++-- 8 files changed, 246 insertions(+), 64 deletions(-) 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 index 03df830d89..77591143e1 100644 --- 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 @@ -18,4 +18,9 @@ public class IncrAndTotalUserIdsResultDTO implements Serializable { private String gridId; private List userIds; + + /** + * userId类型:daily:日,monthly:月 + */ + private String type; } 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 index e48cdda28c..2dcdcdc8f4 100644 --- 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 @@ -16,7 +16,9 @@ public class PartyTotalAndIncrResultDTO implements Serializable { private String gridId; - private Integer incr; + private Integer dailyIncr; + + private Integer monthlyIncr; 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 index d3bf207013..f0886b0399 100644 --- 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 @@ -1,5 +1,6 @@ package com.epmet.dto.user.result; +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; @@ -14,9 +15,17 @@ public class TotalAndIncrResultDTO implements Serializable { private static final long serialVersionUID = -3184476610188193106L; - private Integer total = 0; + private Integer total; - private Integer incr = 0; + private Integer dailyIncr; + + private Integer monthlyIncr; private String gridId; + + public TotalAndIncrResultDTO() { + this.total = NumConstant.ZERO; + this.dailyIncr = NumConstant.ZERO; + this.monthlyIncr = NumConstant.ZERO; + } } 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 index 184d564447..2b9b86e2f0 100644 --- 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 @@ -1,5 +1,6 @@ package com.epmet.dto.user.result; +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; @@ -18,5 +19,19 @@ public class WarmTotalAndIncrResultDTO implements Serializable { private Integer total; - private Integer incr; + /** + * 日增 + */ + private Integer dailyIncr; + + /** + * 月增 + */ + private Integer monthlyIncr; + + public WarmTotalAndIncrResultDTO() { + this.total = NumConstant.ZERO; + this.dailyIncr = NumConstant.ZERO; + this.monthlyIncr = NumConstant.ZERO; + } } 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 2149e8584d..8e03a5abc2 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 @@ -78,8 +78,8 @@ public interface UserDao { * @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); + List selectWarmTotalAndIncrByGrids(@Param("userIds") List userIds, @Param("incrDailyUserIds") List incrDailyUserIds, @Param("gridIds") Set gridIds, + @Param("targetDate") Date targetDate,@Param("startDate") Date startDate,@Param("incrMonthlyUserIds") List incrMonthlyUserIds); /** * @param @@ -90,6 +90,15 @@ public interface UserDao { **/ List selectIncrUserIds(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); + /** + * @param + * @return + * @Description 查询指定网格范围下截至指定位时间累计的注册用户Id + * @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 regOrPartiFlag @@ -98,17 +107,18 @@ public interface UserDao { * @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); + List selectIncrUserIdsByGrids(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate, + @Param("startDate")Date startDate); /** - * @param - * @return - * @Description 查询指定网格范围下截至指定位时间累计的注册用户Id - * @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 regOrPartiFlag + * @Param gridIds + * @Param targetDate + * @author zxc + * @date 2021/7/29 10:08 上午 + */ + List selectTotalUserIdsByGrids(@Param("regOrPartiFlag") String regOrPartiFlag, @Param("gridIds") Set gridIds, @Param("targetDate") Date targetDate); /** * @param 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 5e593a1b79..eefadb4288 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 @@ -722,6 +722,8 @@ public class UserServiceImpl implements UserService { if (CollectionUtils.isEmpty(gridIds)){ return; } + // 是否是月初标志 + Boolean isMonthBeginning = true; dataPacket.setCustomerId(customerId); //计算百分比使用,保留小数点后两位 NumberFormat numberFormat = NumberFormat.getInstance(); @@ -731,27 +733,46 @@ public class UserServiceImpl implements UserService { calendar.setTime(new Date()); calendar.add(Calendar.DATE, NumConstant.ONE_NEG); //指定日期 OR T-1 - calendar.setTime(calendar.getTime()); + calendar.setTime(targetDate); + + //如果目标日期不是是当月的第一天 + if(calendar.get(Calendar.DATE) != calendar.getActualMinimum(Calendar.DAY_OF_MONTH)){ + isMonthBeginning = false; + } //求出这个月的第一天 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.计算机关下注册用户一个时间单位内的累计与增长 + //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<>(); + List incrRegUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_REG, gridIds, targetDate,calendar.getTime()); + List incrDailyUserIds = new ArrayList<>(); + List incrMonthlyUserIds = new ArrayList<>(); if (!CollectionUtils.isEmpty(incrRegUsers)){ - incrRegUsers.forEach(i -> { - if (!CollectionUtils.isEmpty(i.getUserIds())){ - incrUserIds.addAll(i.getUserIds()); - } - }); + // 月增长 和 日增长 分开 + Map> groupByType = incrRegUsers.stream().collect(Collectors.groupingBy(IncrAndTotalUserIdsResultDTO::getType)); + if (!CollectionUtils.isEmpty(groupByType.get(ModuleConstant.DAILY))){ + groupByType.get(ModuleConstant.DAILY).forEach(d -> { + if (!CollectionUtils.isEmpty(d.getUserIds())){ + // 日增长 + incrDailyUserIds.addAll(d.getUserIds()); + } + }); + } + if (!CollectionUtils.isEmpty(groupByType.get(ModuleConstant.MONTHLY))){ + groupByType.get(ModuleConstant.MONTHLY).forEach(m -> { + if (!CollectionUtils.isEmpty(m.getUserIds())){ + // 月增长 + incrMonthlyUserIds.addAll(m.getUserIds()); + } + }); + } } // 全部 - List totalRegUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_REG, gridIds, targetDate,"total",calendar.getTime()); + List totalRegUsers = userDao.selectTotalUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_REG, gridIds, targetDate); List totalUserIds = new ArrayList<>(); if (!CollectionUtils.isEmpty(totalRegUsers)){ totalRegUsers.forEach(t -> { @@ -761,25 +782,39 @@ public class UserServiceImpl implements UserService { }); } //3.查询机关下一个时间单位内热心居民的累计与增量(注册用户) - List warmRegData = userDao.selectWarmTotalAndIncrByGrids(totalUserIds, incrUserIds, gridIds, targetDate,calendar.getTime()); + List warmRegData = userDao.selectWarmTotalAndIncrByGrids(totalUserIds, incrDailyUserIds, gridIds, targetDate,calendar.getTime(),incrMonthlyUserIds); //4.查询机关下一个时间单位内党员的累计与增量(注册用户) List partyRegData = userDao.selectPartyTotalAndIncrNew(targetDate, ModuleConstant.REG_OR_PARTI_FLAG_REG,calendar.getTime()); //参与用户 - //1.计算机关下参与用户一个时间单位内的累计与增长 + //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<>(); + List incrPartiUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_PARTI, gridIds, targetDate, calendar.getTime()); + List incrDailyPartiUserIds = new ArrayList<>(); + List incrMonthlyPartiUserIds = new ArrayList<>(); if (!CollectionUtils.isEmpty(incrPartiUsers)){ - incrPartiUsers.forEach(i -> { - if (!CollectionUtils.isEmpty(i.getUserIds())){ - incrPartiUserIds.addAll(i.getUserIds()); - } - }); + // 月增长 和 天增长 分开 + Map> groupByType = incrRegUsers.stream().collect(Collectors.groupingBy(IncrAndTotalUserIdsResultDTO::getType)); + if (!CollectionUtils.isEmpty(groupByType.get(ModuleConstant.DAILY))){ + groupByType.get(ModuleConstant.DAILY).forEach(d -> { + if (!CollectionUtils.isEmpty(d.getUserIds())){ + // 日增长 + incrDailyPartiUserIds.addAll(d.getUserIds()); + } + }); + } + if (!CollectionUtils.isEmpty(groupByType.get(ModuleConstant.MONTHLY))){ + groupByType.get(ModuleConstant.MONTHLY).forEach(m -> { + if (!CollectionUtils.isEmpty(m.getUserIds())){ + // 月增长 + incrMonthlyPartiUserIds.addAll(m.getUserIds()); + } + }); + } } // 查询参与用户的Id列表[全部] - List totalPartiUsers = userDao.selectIncrUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_PARTI, gridIds, targetDate, "total",calendar.getTime()); + List totalPartiUsers = userDao.selectTotalUserIdsByGrids(ModuleConstant.REG_OR_PARTI_FLAG_PARTI, gridIds, targetDate); List totalPartiUserIds = new ArrayList<>(); if (!CollectionUtils.isEmpty(totalPartiUsers)){ totalPartiUsers.forEach(t -> { @@ -789,7 +824,7 @@ public class UserServiceImpl implements UserService { }); } //3.查询机关下一个时间单位内热心居民的累计与增量(参与用户) - List warmPartiData = userDao.selectWarmTotalAndIncrByGrids(totalPartiUserIds, incrPartiUserIds, gridIds, targetDate,calendar.getTime()); + List warmPartiData = userDao.selectWarmTotalAndIncrByGrids(totalPartiUserIds, incrDailyPartiUserIds, gridIds, targetDate,calendar.getTime(),incrMonthlyPartiUserIds); //4.查询机关下一个时间单位内党员的累计与增量(参与用户) List partyPartiData = userDao.selectPartyTotalAndIncrNew(targetDate, ModuleConstant.REG_OR_PARTI_FLAG_PARTI,calendar.getTime()); @@ -840,10 +875,10 @@ public class UserServiceImpl implements UserService { if (gridId.equals(r.getGridId())){ regGridD.setResiTotal(r.getTotal()); regGridD.setRegTotal(r.getTotal()); - regGridD.setRegIncr(r.getIncr()); + regGridD.setRegIncr(r.getDailyIncr()); regGridM.setRegTotal(r.getTotal()); regGridM.setResiTotal(r.getTotal()); - regGridM.setRegIncr(r.getIncr()); + regGridM.setRegIncr(r.getMonthlyIncr()); break; } } @@ -852,9 +887,9 @@ public class UserServiceImpl implements UserService { for (WarmTotalAndIncrResultDTO w : warmRegData) { if (gridId.equals(w.getGridId())){ regGridD.setWarmHeartedTotal(w.getTotal()); - regGridD.setWarmIncr(w.getIncr()); + regGridD.setWarmIncr(w.getDailyIncr()); regGridM.setWarmHeartedTotal(w.getTotal()); - regGridM.setWarmIncr(w.getIncr()); + regGridM.setWarmIncr(w.getMonthlyIncr()); break; } } @@ -864,10 +899,10 @@ public class UserServiceImpl implements UserService { if (gridId.equals(p.getGridId())){ partiGridD.setResiTotal(p.getTotal()); partiGridD.setRegTotal(p.getTotal()); - partiGridD.setRegIncr(p.getIncr()); + partiGridD.setRegIncr(p.getDailyIncr()); partiGridM.setRegTotal(p.getTotal()); partiGridM.setResiTotal(p.getTotal()); - partiGridM.setRegIncr(p.getIncr()); + partiGridM.setRegIncr(p.getMonthlyIncr()); break; } } @@ -876,11 +911,11 @@ public class UserServiceImpl implements UserService { for (PartyTotalAndIncrResultDTO p : partyRegData) { if (gridId.equals(p.getGridId())){ regGridD.setPartymemberTotal(p.getTotal()); - regGridD.setPartymemberIncr(p.getIncr()); + regGridD.setPartymemberIncr(p.getDailyIncr()); regGridM.setPartymemberTotal(p.getTotal()); - regGridM.setPartymemberIncr(p.getIncr()); + regGridM.setPartymemberIncr(p.getMonthlyIncr()); regGridM.setPartymemberTotal(p.getTotal()); - regGridM.setPartymemberIncr(p.getIncr()); + regGridM.setPartymemberIncr(p.getMonthlyIncr()); break; } } @@ -889,9 +924,9 @@ public class UserServiceImpl implements UserService { for (WarmTotalAndIncrResultDTO w : warmPartiData) { if (gridId.equals(w.getGridId())){ partiGridD.setWarmHeartedTotal(w.getTotal()); - partiGridD.setWarmIncr(w.getIncr()); + partiGridD.setWarmIncr(w.getDailyIncr()); partiGridM.setWarmHeartedTotal(w.getTotal()); - partiGridM.setWarmIncr(w.getIncr()); + partiGridM.setWarmIncr(w.getMonthlyIncr()); break; } } @@ -900,9 +935,9 @@ public class UserServiceImpl implements UserService { for (PartyTotalAndIncrResultDTO p : partyPartiData) { if (gridId.equals(p.getGridId())){ partiGridD.setPartymemberTotal(p.getTotal()); - partiGridD.setPartymemberIncr(p.getIncr()); + partiGridD.setPartymemberIncr(p.getDailyIncr()); partiGridM.setPartymemberTotal(p.getTotal()); - partiGridM.setPartymemberIncr(p.getIncr()); + partiGridM.setPartymemberIncr(p.getMonthlyIncr()); break; } } 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 index 1881ed5c77..8b06b9688b 100644 --- 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 @@ -43,4 +43,8 @@ public interface ModuleConstant { String TOPIC_STATUS_SHIFT_ISSUE = "shift_issue"; String NEED_UPDATE_STATUS_TOPIC = "needUpdateStatusTopic"; + + String MONTHLY = "monthly"; + + String DAILY = "daily"; } 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 727b653266..a4a31ca6b2 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 @@ -632,7 +632,8 @@ SELECT IFNULL(count( DISTINCT rr.USER_ID ),0) AS total, rr.GRID_ID, - IFNULL(t.userCount,0) AS incr + IFNULL(t.userCount,0) AS monthlyIncr, + IFNULL(d.userCount,0) AS dailyIncr FROM REGISTER_RELATION rr LEFT JOIN ( SELECT @@ -656,6 +657,24 @@ ,"%Y-%m-%d") GROUP BY GRID_ID ) t ON ( t.grid_id = rr.GRID_ID ) + LEFT JOIN ( + SELECT + IFNULL(count(DISTINCT USER_ID),0) AS userCount, + GRID_ID + FROM REGISTER_RELATION + WHERE DEL_FLAG = '0' + + AND ((FIRST_REGISTER = '1' AND REGISTER = '1' AND PARTICIPATION = '1') OR (FIRST_REGISTER = '0' AND REGISTER = '0' AND PARTICIPATION = '1')) + + + AND FIRST_REGISTER = '1' + + + GRID_ID = #{gridId} + + AND DATE_FORMAT(CREATED_TIME,"%Y-%m-%d") = DATE_FORMAT(IF(null != #{targetDate} OR '' !=#{targetDate},#{targetDate},DATE_SUB(CURDATE(), INTERVAL 1 DAY )),"%Y-%m-%d") + GROUP BY GRID_ID + ) d ON ( d.grid_id = rr.GRID_ID ) WHERE rr.DEL_FLAG = '0' @@ -673,15 +692,17 @@ + @@ -710,7 +744,8 @@ SELECT IFNULL(COUNT(DISTINCT ur.USER_ID),0) AS total, ur.GRID_ID, - IFNULL(t.userCount,0) AS incr + IFNULL(t.userCount,0) AS monthlyIncr, + IFNULL(d.userCount,0) AS dailyIncr FROM USER_ROLE ur LEFT JOIN EPMET_ROLE erole ON ( ur.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0' ) LEFT JOIN ( @@ -720,8 +755,8 @@ FROM USER_ROLE ur LEFT JOIN EPMET_ROLE erole ON (ur.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0') WHERE ur.DEL_FLAG = '0' - - + + ur.USER_ID = #{incrUserId} @@ -733,9 +768,28 @@ AND erole.ROLE_NAME = '热心居民' GROUP BY ur.GRID_ID ) t ON ( t.GRID_ID = ur.GRID_ID ) + LEFT JOIN ( + SELECT + COUNT( DISTINCT ur.USER_ID ) AS userCount, + ur.GRID_ID + FROM USER_ROLE ur + LEFT JOIN EPMET_ROLE erole ON (ur.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0') + WHERE ur.DEL_FLAG = '0' + + + ur.USER_ID = #{incrUserId} + + + + ur.GRID_ID = #{gridId} + + AND DATE_FORMAT(ur.CREATED_TIME,"%Y-%m-%d") = DATE_FORMAT(IF(null != #{targetDate} OR '' !=#{targetDate},#{targetDate},DATE_SUB(CURDATE(),INTERVAL 1 DAY)),"%Y-%m-%d") + AND erole.ROLE_NAME = '热心居民' + GROUP BY ur.GRID_ID + ) d ON ( d.GRID_ID = ur.GRID_ID ) WHERE ur.DEL_FLAG = '0' - - + + ur.USER_ID = #{incrUserId} @@ -752,7 +806,8 @@ SELECT IFNULL(count(urole.USER_ID),0) AS total, rr.GRID_ID, - IFNULL(t.userCount,0) AS incr + IFNULL(t.userCount,0) AS monthlyIncr, + IFNULL(d.userCount,0) AS dailyIncr FROM USER_ROLE urole LEFT JOIN EPMET_ROLE erole ON (urole.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0') LEFT JOIN register_relation rr ON (rr.USER_ID = urole.USER_ID) @@ -776,6 +831,25 @@ GROUP BY rr.GRID_ID ) t ON (t.GRID_ID = rr.GRID_ID) + LEFT JOIN ( + SELECT + count(urole.USER_ID) AS userCount, + rr.GRID_ID + FROM USER_ROLE urole + LEFT JOIN EPMET_ROLE erole ON (urole.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0') + LEFT JOIN register_relation rr ON (rr.USER_ID = urole.USER_ID) + WHERE + urole.DEL_FLAG = '0' + AND erole.ROLE_NAME = '党员' + AND DATE_FORMAT(rr.CREATED_TIME,"%Y-%m-%d") = DATE_FORMAT(IF(null != #{targetDate} OR '' !=#{targetDate},#{targetDate},DATE_SUB(CURDATE(),INTERVAL 1 DAY)),"%Y-%m-%d") + + AND ((rr.FIRST_REGISTER = '1' AND rr.REGISTER = '1' AND rr.PARTICIPATION = '1') OR (rr.FIRST_REGISTER = '0' AND rr.REGISTER = '0' AND rr.PARTICIPATION = '1')) + + + AND rr.FIRST_REGISTER = '1' + + GROUP BY rr.GRID_ID + ) d ON (d.GRID_ID = rr.GRID_ID) WHERE urole.DEL_FLAG = '0' AND DATE_FORMAT(rr.CREATED_TIME,"%Y-%m-%d") DATE_FORMAT( IF(null != #{targetDate} OR '' != #{targetDate},#{targetDate}, DATE_SUB(CURDATE(),INTERVAL 1 DAY)),'%Y-%m-%d') @@ -811,6 +885,34 @@ GROUP BY GRID_ID + + + + + + + + + DELETE FROM From 13335b286da549b5a24605d74b823ff111ffa801 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 29 Jul 2021 14:05:56 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/user/UserDao.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a4a31ca6b2..c465d7cc41 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 @@ -813,7 +813,7 @@ LEFT JOIN register_relation rr ON (rr.USER_ID = urole.USER_ID) LEFT JOIN ( SELECT - count(urole.USER_ID) AS userCount, + count(distinct urole.USER_ID) AS userCount, rr.GRID_ID FROM USER_ROLE urole LEFT JOIN EPMET_ROLE erole ON (urole.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0') @@ -833,7 +833,7 @@ ) t ON (t.GRID_ID = rr.GRID_ID) LEFT JOIN ( SELECT - count(urole.USER_ID) AS userCount, + count(distinct urole.USER_ID) AS userCount, rr.GRID_ID FROM USER_ROLE urole LEFT JOIN EPMET_ROLE erole ON (urole.ROLE_ID = erole.ID AND erole.DEL_FLAG = '0') From e220b22c7cea3bbfaae247493ee42526680fe8cc Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 29 Jul 2021 14:18:51 +0800 Subject: [PATCH 6/9] .. --- .../src/main/resources/mapper/user/UserDao.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c465d7cc41..ed15209bbe 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 @@ -804,7 +804,7 @@ (SELECT DISTINCT(USER_ID) AS userIds, - GRID_ID, + GRID_ID AS gridId, 'monthly' AS type FROM REGISTER_RELATION @@ -895,7 +895,7 @@ (SELECT - DISTINCT(USER_ID) AS userIds, + DISTINCT(USER_ID) AS userId, GRID_ID AS gridId, 'monthly' AS type FROM @@ -889,12 +889,12 @@ - + SELECT diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml index 855007785a..3081816026 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml @@ -104,6 +104,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridMonthlyDao.xml index 821ca24983..ae1950cdd4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridMonthlyDao.xml @@ -104,6 +104,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 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 d783989020..936f553485 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 @@ -700,43 +700,44 @@ @@ -894,23 +895,22 @@