Browse Source

又一次优化☹️

dev_shibei_match
zxc 4 years ago
parent
commit
b1ba7f6b63
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyDailyDao.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserAgencyMonthlyDao.java
  3. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridDailyDao.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactParticipationUserGridMonthlyDao.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyDailyDao.java
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserAgencyMonthlyDao.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridDailyDao.java
  8. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/user/FactRegUserGridMonthlyDao.java
  9. 53
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/user/impl/UserStatisticalServiceImpl.java
  10. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
  11. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml
  12. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyMonthlyDao.xml
  13. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml
  14. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridMonthlyDao.xml
  15. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyDailyDao.xml
  16. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyMonthlyDao.xml
  17. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml
  18. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridMonthlyDao.xml
  19. 58
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml

2
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<FactPartici
void insertBatch(@Param("list") List<FactParticipationUserAgencyDailyDTO> list);
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
/**
* @Description 查询机关下用户信息

2
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<FactParti
void insertBatch(@Param("list") List<FactParticipationUserAgencyMonthlyDTO> list);
void deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId);
}

2
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<FactParticipa
void insertBatch(@Param("list") List<FactParticipationUserGridDailyDTO> list);
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
/**
* @Description 查询网格下用户信息

2
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<FactPartici
void insertBatch(@Param("list") List<FactParticipationUserGridMonthlyDTO> list);
void deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId);
}

2
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<FactRegUserAgencyDail
void insertBatch(@Param("list") List<FactRegUserAgencyDailyDTO> list);
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
}

2
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<FactRegUserAgencyMo
void insertBatch(@Param("list") List<FactRegUserAgencyMonthlyDTO> list);
void deleteByParams(@Param("monthId") String monthId, @Param("customerId") String customerId);
Integer deleteByParams(@Param("monthId") String monthId, @Param("customerId") String customerId);
List<GridUserCountResultDTO> selectAgencyUserCount(@Param("customerId") String customerId, @Param("monthId") String monthId);

2
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<FactRegUserGridDailyEnt
void insertBatch(@Param("list") List<FactRegUserGridDailyDTO> list);
void deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("dateId")String dateId,@Param("customerId")String customerId);
/**
* @Description 根据机构级别查询用户数与党员数

2
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<FactRegUserGridMonthl
void insertBatch(@Param("list") List<FactRegUserGridMonthlyDTO> list);
void deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId);
Integer deleteByParams(@Param("monthId")String monthId,@Param("customerId")String customerId);
/**
* @Description 查询网格下的客户

53
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<List<FactParticipationUserAgencyDailyDTO>> 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<List<FactParticipationUserAgencyMonthlyDTO>> 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<List<FactParticipationUserGridMonthlyDTO>> 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<List<FactParticipationUserGridDailyDTO>> 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<List<FactRegUserAgencyDailyDTO>> 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<List<FactRegUserAgencyMonthlyDTO>> 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<List<FactRegUserGridDailyDTO>> 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<List<FactRegUserGridMonthlyDTO>> partition = ListUtils.partition(data.getRegGridMonthlyList(), NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
regUserGridMonthlyDao.insertBatch(p);
});
}
}

14
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);

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyDailyDao.xml

@ -100,6 +100,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>
<!-- 查询机关下用户信息 -->

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserAgencyMonthlyDao.xml

@ -100,6 +100,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridDailyDao.xml

@ -105,6 +105,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>
<!-- 查询网格下用户信息 -->

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactParticipationUserGridMonthlyDao.xml

@ -104,6 +104,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyDailyDao.xml

@ -100,6 +100,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserAgencyMonthlyDao.xml

@ -100,6 +100,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>
<select id="selectOrgUserCountByCustomer" resultType="com.epmet.dto.stats.user.FactRegUserAgencyMonthlyDTO">
SELECT

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridDailyDao.xml

@ -104,6 +104,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/user/FactRegUserGridMonthlyDao.xml

@ -104,6 +104,7 @@
<if test='null != customerId and "" != customerId'>
AND CUSTOMER_ID = #{customerId}
</if>
LIMIT 1000
</delete>
<!-- 查询网格下的客户 -->

58
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml

@ -700,43 +700,44 @@
<!-- 查询指定网格范围下单位时间内新增的注册用户Id【新方法】 -->
<select id="selectIncrUserIdsByGrids" resultMap="selectIncrUserIdsByGridsMap">
(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'
<if test='regOrPartiFlag == "parti" '>
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'))
</if>
<if test='regOrPartiFlag == "reg" '>
AND FIRST_REGISTER = '1'
AND rr.FIRST_REGISTER = '1'
</if>
<foreach collection="gridIds" item="gridId" index="index" open="AND ( " separator=" OR " close=")">
GRID_ID = #{gridId}
rr.GRID_ID = #{gridId}
</foreach>
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'
<if test='regOrPartiFlag == "parti" '>
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'))
</if>
<if test='regOrPartiFlag == "reg" '>
AND FIRST_REGISTER = '1'
AND rr.FIRST_REGISTER = '1'
</if>
<foreach collection="gridIds" item="gridId" index="index" open="AND ( " separator=" OR " close=")">
GRID_ID = #{gridId}
rr.GRID_ID = #{gridId}
</foreach>
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")
)
</select>
<!-- 查询热心居民的总量与增量【新方法】 -->
@ -894,23 +895,22 @@
</resultMap>
<select id="selectTotalUserIdsByGrids" resultMap="selectTotalUserIdsByGridsMap">
SELECT
DISTINCT(USER_ID) AS userId,
GRID_ID AS gridId
FROM
REGISTER_RELATION
DISTINCT(rr.USER_ID) AS userId,
r2.GRID_ID AS gridId
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'
<if test='regOrPartiFlag == "parti" '>
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'))
</if>
<if test='regOrPartiFlag == "reg" '>
AND FIRST_REGISTER = '1'
AND rr.FIRST_REGISTER = '1'
</if>
<foreach collection="gridIds" item="gridId" index="index" open="AND ( " separator=" OR " close=")">
GRID_ID = #{gridId}
rr.GRID_ID = #{gridId}
</foreach>
AND DATE_FORMAT(CREATED_TIME,"%Y-%m-%d") <![CDATA[<=]]> IF(null != #{targetDate} OR '' !=#{targetDate},DATE_FORMAT(#{targetDate},"%Y-%m-%d"),DATE_FORMAT( DATE_SUB( CURDATE( ), INTERVAL 1 DAY ),"%Y-%m-%d"))
GROUP BY GRID_ID
AND DATE_FORMAT(rr.CREATED_TIME,"%Y-%m-%d") <![CDATA[<=]]> IF(null != #{targetDate} OR '' !=#{targetDate},DATE_FORMAT(#{targetDate},"%Y-%m-%d"),DATE_FORMAT( DATE_SUB( CURDATE( ), INTERVAL 1 DAY ),"%Y-%m-%d"))
</select>
<delete id="delGmUploadEvent">

Loading…
Cancel
Save