diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java index f74e27ede1..8231cc4e7a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java @@ -37,7 +37,7 @@ public interface FactParticipationUserAgencyDailyDao extends BaseDao list); - void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); /** * @Description 查询机关下用户信息 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyMonthlyDao.java index d52897c4b9..4f3f570d27 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyMonthlyDao.java @@ -36,6 +36,6 @@ public interface FactParticipationUserAgencyMonthlyDao extends BaseDao list); - void deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java index 687e8650d6..acd5329dd4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java @@ -38,7 +38,7 @@ public interface FactParticipationUserGridDailyDao extends BaseDao list); - void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); /** * @Description 查询网格下用户信息 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridMonthlyDao.java index b67adec9dc..ec04d3a275 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridMonthlyDao.java @@ -36,5 +36,5 @@ public interface FactParticipationUserGridMonthlyDao extends BaseDao list); - void deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyDailyDao.java index e22a094565..b26b96ec63 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyDailyDao.java @@ -36,6 +36,6 @@ public interface FactRegUserAgencyDailyDao extends BaseDao list); - void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyMonthlyDao.java index 5df37b7ff5..633df1abb2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyMonthlyDao.java @@ -37,7 +37,7 @@ public interface FactRegUserAgencyMonthlyDao extends BaseDao list); - void deleteByParams(@Param("monthId") String monthId, @Param("customerId") String customerId); + Integer deleteByParams(@Param("monthId") String monthId, @Param("customerId") String customerId); List selectAgencyUserCount(@Param("customerId") String customerId, @Param("monthId") String monthId); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java index ba2c53eb2c..d0b24b16f3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java @@ -37,7 +37,7 @@ public interface FactRegUserGridDailyDao extends BaseDao list); - void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId); /** * @Description 根据机构级别查询用户数与党员数 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridMonthlyDao.java index 744f9ffd0a..3eef3fda97 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridMonthlyDao.java @@ -37,7 +37,7 @@ public interface FactRegUserGridMonthlyDao extends BaseDao list); - void deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId); + Integer deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId); /** * @Description 查询网格下的客户 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 b483355a0a..50b3ade54f 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 @@ -63,8 +63,10 @@ public class UserStatisticalServiceImpl implements UserStatisticalService { } if(null != data.getPartiAgencyDailyList() && data.getPartiAgencyDailyList().size() > NumConstant.ZERO){ - - participationUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); + Integer delNum; + do { + delNum = participationUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); List> partition = ListUtils.partition(data.getPartiAgencyDailyList(), NumConstant.ONE_HUNDRED); partition.forEach(p -> { participationUserAgencyDailyDao.insertBatch(p); @@ -72,8 +74,10 @@ public class UserStatisticalServiceImpl implements UserStatisticalService { } if(null != data.getPartiAgencyMonthlyList() && data.getPartiAgencyMonthlyList().size() > NumConstant.ZERO){ - - participationUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); + Integer delNum; + do { + delNum = participationUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); List> partition = ListUtils.partition(data.getPartiAgencyMonthlyList(), NumConstant.ONE_HUNDRED); partition.forEach(p -> { participationUserAgencyMonthlyDao.insertBatch(p); @@ -81,8 +85,10 @@ public class UserStatisticalServiceImpl implements UserStatisticalService { } if(null != data.getPartiGridMonthlyList() && data.getPartiGridMonthlyList().size() > NumConstant.ZERO){ - - participationUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); + Integer delNum; + do { + delNum = participationUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); List> partition = ListUtils.partition(data.getPartiGridMonthlyList(), NumConstant.ONE_HUNDRED); partition.forEach(p -> { participationUserGridMonthlyDao.insertBatch(p); @@ -90,53 +96,58 @@ public class UserStatisticalServiceImpl implements UserStatisticalService { } if(null != data.getPartiGridDailyList() && data.getPartiGridDailyList().size() > NumConstant.ZERO){ - - participationUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); + Integer delNum; + do { + delNum = participationUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); 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()); + Integer delNum; + do { + delNum = regUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); 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()); + Integer delNum; + do { + delNum = regUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); 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()); + Integer delNum; + do { + delNum = regUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); 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()); + Integer delNum; + do { + delNum = regUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); 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 eefadb4288..c154ead20b 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,23 +722,11 @@ public class UserServiceImpl implements UserService { if (CollectionUtils.isEmpty(gridIds)){ return; } - // 是否是月初标志 - Boolean isMonthBeginning = true; 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(targetDate); - - //如果目标日期不是是当月的第一天 - if(calendar.get(Calendar.DATE) != calendar.getActualMinimum(Calendar.DAY_OF_MONTH)){ - isMonthBeginning = false; - } + Calendar calendar = Calendar.getInstance(); //求出这个月的第一天 calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE); calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml index f23abdcbf1..b59659027a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml @@ -100,6 +100,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyMonthlyDao.xml index 7215527ed6..3ff5542f39 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyMonthlyDao.xml @@ -100,6 +100,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml index 30c5f5c39c..6777cfdbbe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml @@ -105,6 +105,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridMonthlyDao.xml index cfe17cd854..e365dd1022 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridMonthlyDao.xml @@ -104,6 +104,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyDailyDao.xml index 185a97da77..85baff9c08 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyDailyDao.xml @@ -100,6 +100,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyMonthlyDao.xml index 7d01629a99..f3a23413cc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyMonthlyDao.xml @@ -100,6 +100,7 @@ AND CUSTOMER_ID = #{customerId} + LIMIT 1000 (SELECT - DISTINCT(USER_ID) AS userId, - GRID_ID AS gridId, + DISTINCT(rr.USER_ID) AS userId, + r2.GRID_ID AS gridId, 'monthly' AS type - FROM - REGISTER_RELATION + FROM REGISTER_RELATION rr + LEFT JOIN register_relation r2 ON (r2.GRID_ID = rr.GRID_ID AND r2.DEL_FLAG = 0) WHERE - DEL_FLAG = '0' + rr.DEL_FLAG = '0' - AND ((FIRST_REGISTER = '1' AND REGISTER = '1' AND PARTICIPATION = '1') OR (FIRST_REGISTER = '0' AND REGISTER = '0' AND PARTICIPATION = '1')) + 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 FIRST_REGISTER = '1' + AND rr.FIRST_REGISTER = '1' - GRID_ID = #{gridId} + rr.GRID_ID = #{gridId} - AND DATE_FORMAT(CREATED_TIME,"%Y-%m-%d") BETWEEN DATE_FORMAT(#{startDate},"%Y-%m-%d") AND + AND DATE_FORMAT(rr.CREATED_TIME,"%Y-%m-%d") BETWEEN DATE_FORMAT(#{startDate},"%Y-%m-%d") AND DATE_FORMAT(IF(null != #{targetDate} OR '' !=#{targetDate},#{targetDate},DATE_SUB(CURDATE(),INTERVAL 1 DAY)),"%Y-%m-%d") - GROUP BY GRID_ID) UNION ALL + ) UNION ALL (SELECT - DISTINCT(USER_ID) AS userIds, - GRID_ID, + DISTINCT(rr.USER_ID) AS userId, + r2.GRID_ID AS gridId, 'daily' AS type - FROM REGISTER_RELATION + FROM REGISTER_RELATION rr + LEFT JOIN register_relation r2 ON (r2.GRID_ID = rr.GRID_ID AND r2.DEL_FLAG = 0) WHERE - DEL_FLAG = '0' + rr.DEL_FLAG = '0' - AND ((FIRST_REGISTER = '1' AND REGISTER = '1' AND PARTICIPATION = '1') OR (FIRST_REGISTER = '0' AND REGISTER = '0' AND PARTICIPATION = '1')) + 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 FIRST_REGISTER = '1' + AND rr.FIRST_REGISTER = '1' - GRID_ID = #{gridId} + rr.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) + 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") + ) @@ -894,23 +895,22 @@