From fe4288e7f3cf8def3b2fdab9f56f85e6e1e700ef Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 18 Sep 2020 10:34:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E5=91=98=E7=9B=B8=E5=85=B3-=E5=85=9A?= =?UTF-8?q?=E5=BB=BA=E8=83=BD=E5=8A=9B=E8=AE=A1=E7=AE=97V0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FactIndexPartyAblityCpcMonthlyDao.java | 9 ++ .../dao/stats/DimCustomerPartymemberDao.java | 10 ++ .../extract/CalCpcIndexService.java | 19 ++++ .../extract/impl/CalCpcIndexServiceImpl.java | 97 +++++++++++++++++++ .../stats/DimCustomerPartymemberService.java | 10 ++ .../DimCustomerPartymemberServiceImpl.java | 16 +++ .../FactIndexPartyAblityCpcMonthlyDao.xml | 60 +++++++++++- .../stats/DimCustomerPartymemberDao.xml | 30 ++++++ 8 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/CalCpcIndexService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java index 824b7a04a1..619b621d7a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java @@ -62,4 +62,13 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize); Map getExtremeValue(@Param("customerId") String customerId, @Param("monthId") String monthId); + + /** + * @return int + * @param list + * @author yinzuomei + * @description 批量插入 入参为entity + * @Date 2020/9/18 10:30 + **/ + int insertBatchEntity(@Param("list") List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java index afab95849a..eee170f6f7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java @@ -19,6 +19,7 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.stats.form.DimCustomerPartyMemberFormDTO; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.entity.stats.DimCustomerPartymemberEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -50,4 +51,13 @@ public interface DimCustomerPartymemberDao extends BaseDao + * @param customerId 客户id + * @author yinzuomei + * @description 查询客户下所有的党员, 构造好党员相关-党建能力初始值 + * @Date 2020/9/18 9:00 + **/ + List selectPartyMemberList(String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/CalCpcIndexService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/CalCpcIndexService.java new file mode 100644 index 0000000000..dbbfa63563 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/CalCpcIndexService.java @@ -0,0 +1,19 @@ +package com.epmet.service.evaluationindex.extract; + +/** + * 党员相关 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/17 14:05 + */ +public interface CalCpcIndexService { + /** + * @return void + * @param customerId 客户id + * @param monthId yyyyMM + * @author yinzuomei + * @description 党员相关-党建能力 + * @Date 2020/9/17 14:08 + **/ + void calCpcPartyAbility(String customerId, String monthId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java new file mode 100644 index 0000000000..758ff8d51e --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java @@ -0,0 +1,97 @@ +package com.epmet.service.evaluationindex.extract.impl; + +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao; +import com.epmet.entity.evaluationindex.extract.FactOriginTopicLogDailyEntity; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; +import com.epmet.service.evaluationindex.extract.CalCpcIndexService; +import com.epmet.service.stats.DimCustomerPartymemberService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 党员相关 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/17 14:06 + */ +@Slf4j +@Service +public class CalCpcIndexServiceImpl implements CalCpcIndexService { + @Autowired + private DimCustomerPartymemberService dimCustomerPartymemberService; + @Autowired + private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; + + /** + * @param customerId 客户id + * @param monthId yyyyMM + * @return void + * @author yinzuomei + * @description 党员相关-党建能力 + * @Date 2020/9/17 14:08 + **/ + @Override + public void calCpcPartyAbility(String customerId, String monthId) { + //1、构造初始值 + List indexPartyAblityCpcList = dimCustomerPartymemberService.selectPartyMemberList(customerId); + //2、删除之前统计过的 + deleteFactIndexPartyAblityCpcMonthly(customerId, monthId); + //3、计算实际值,更新 + for (FactIndexPartyAblityCpcMonthlyEntity indexPartyAblityCpcEntity : indexPartyAblityCpcList) { + //TODO + //党员提出话题数 + //党员参与话题数(支持、反对、评论、浏览) + //党员提出的话题转议题数 + //党员提出的议题转项目数 + //参加“三会一课”次数 + //党员自建群群众人数 + //党员自建群活跃群众人数 + //党员自建群活跃度——话题数 + //自建群活跃度——议题转项目率 + } + //4、分批插入 + //批量插入 + List> partition = ListUtils.partition(indexPartyAblityCpcList, IndexCalConstant.INSERT_SIZE); + partition.forEach(list -> { + this.FactIndexPartyAblityCpcMonthlyEntity(list); + }); + } + + + /** + * @param customerId + * @param monthId + * @return void + * @author yinzuomei + * @description 删除这个客户这个月 党员相关-党建能力的数据 + * @Date 2020/9/18 10:20 + **/ + @DataSource(value = DataSourceConstant.EVALUATION_INDEX) + public void deleteFactIndexPartyAblityCpcMonthly(String customerId, String monthId) { + int deleteNum; + do { + deleteNum = factIndexPartyAblityCpcMonthlyDao.deleteFactIndexPartyAblityCpcMonthly(customerId, monthId); + } while (deleteNum > NumConstant.ZERO); + } + + /** + * @param list + * @return void + * @author yinzuomei + * @description 批量插入党员相关党建能力表 + * @Date 2020/9/18 10:27 + **/ + @DataSource(value = DataSourceConstant.EVALUATION_INDEX) + private void FactIndexPartyAblityCpcMonthlyEntity(List list) { + factIndexPartyAblityCpcMonthlyDao.insertBatchEntity(list); + } + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerPartymemberService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerPartymemberService.java index 267eca8c73..137aebedbe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerPartymemberService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerPartymemberService.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.stats.DimCustomerPartymemberDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.entity.stats.DimCustomerPartymemberEntity; import java.util.List; @@ -101,4 +102,13 @@ public interface DimCustomerPartymemberService extends BaseService + * @param customerId 客户id + * @author yinzuomei + * @description 查询客户下所有的党员, 构造好党员相关-党建能力初始值 + * @Date 2020/9/18 9:03 + **/ + List selectPartyMemberList(String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java index 69f09d0ce0..af0e3f5e0a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java @@ -19,6 +19,7 @@ package com.epmet.service.stats.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.dto.form.TimeListResultDTO; import com.epmet.commons.tools.exception.RenException; @@ -26,12 +27,14 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.DataSourceConstant; import com.epmet.constant.StatsConstant; import com.epmet.dao.stats.DimCustomerPartymemberDao; import com.epmet.dto.stats.DimCustomerPartymemberDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.dto.stats.form.DimCustomerPartyMemberFormDTO; import com.epmet.dto.stats.result.GridBelongAgencyResultDTO; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.entity.stats.DimCustomerPartymemberEntity; import com.epmet.service.partymember.PartyMemberService; import com.epmet.service.stats.DimCustomerPartymemberService; @@ -155,6 +158,19 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl + * @author yinzuomei + * @description 查询客户下所有的党员, 构造好党员相关-党建能力初始值 + * @Date 2020/9/18 9:03 + **/ + @DataSource(value = DataSourceConstant.STATS) + @Override + public List selectPartyMemberList(String customerId) { + return baseDao.selectPartyMemberList(customerId); + } + /** * @Description 删除旧纪录,插入新纪录 * @param partyMemberList diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml index 443d22edfa..788af38336 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml @@ -125,5 +125,63 @@ LIMIT #{offset},#{pageSize} - + + + insert into fact_index_party_ablity_cpc_monthly + ( + ID, + CUSTOMER_ID, + AGENCY_ID, + PARENT_ID, + GRID_ID, + MONTH_ID, + QUARTER_ID, + YEAR_ID, + CREATE_TOPIC_COUNT, + JOIN_TOPIC_COUNT, + SHIFT_ISSUE_COUNT, + SHIFT_PROJECT_COUNT, + JOIN_THREE_MEETS_COUNT, + GROUP_USER_COUNT, + GROUP_TOPIC_COUNT, + TOPIC_TO_ISSUE_RATIO, + GROUP_ACTIVE_USER_COUNT, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME, + USER_ID + ) values + + ( + (SELECT REPLACE(UUID(), '-', '') AS id), + #{item.customerId}, + #{item.agencyId}, + #{item.parentId}, + #{item.gridId}, + #{item.monthId}, + #{item.quarterId}, + #{item.yearId}, + #{item.createTopicCount}, + #{item.joinTopicCount}, + #{item.shiftIssueCount}, + #{item.shiftProjectCount}, + #{item.joinThreeMeetsCount}, + #{item.groupUserCount}, + #{item.groupTopicCount}, + #{item.topicToIssueRatio}, + #{item.groupActiveUserCount}, + 0, + 0, + 'APP_USER', + now(), + 'APP_USER', + now(), + #{item.userId} + ) + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml index 8dbc158531..04b111bef6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml @@ -59,4 +59,34 @@ CUSTOMER_ID = #{customerId} AND DATE_ID = #{dateId} + + + + \ No newline at end of file