diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java index 6daa79d0bf..b20619837c 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java @@ -13,4 +13,5 @@ public interface DataSourceConstant { String EPMET_USER = "epmetuser"; String EVALUATION_INDEX = "evaluationIndex"; String PARTY_MEMBER = "partyMember"; + String EPMET_HEART="epmetHeart"; } diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 1e0916c69d..18ef4bc7f6 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -210,6 +210,12 @@ epmet_resi_partymember_user EpmEt-db-UsEr + + + + epmet_heart_user + EpmEt-db-UsEr + 0 192.168.1.130 @@ -314,6 +320,12 @@ epmet_resi_partymember_user EpmEt-db-UsEr + + + + epmet_heart_user + EpmEt-db-UsEr + 0 192.168.1.130 @@ -418,6 +430,12 @@ epmet elink@833066 + + + + epmet + elink@833066 + 0 r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com @@ -518,6 +536,12 @@ epmet_resi_partymember_user EpmEt-db-UsEr + + + + epmet_heart_user + EpmEt-db-UsEr + 0 r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.java index 1ef6d38f42..10cabe11f1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.java @@ -96,4 +96,22 @@ public interface FactIndexServiceAblityGridMonthlyDao extends BaseDao + * @param customerId + * @author yinzuomei + * @description 查询出所有的网格,初始化好 服务能力-网格相关事实表 各个指标值赋值为0 + * @Date 2020/9/21 9:42 + **/ + List initAllGridList(String customerId); + + /** + * @return void + * @param list + * @author yinzuomei + * @description 批量插入网格相关-服务能力指标表 + * @Date 2020/9/21 10:13 + **/ + void insertBatchEntity(@Param("list") List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java new file mode 100644 index 0000000000..5c3dfddd3d --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/ActInfoDao.java @@ -0,0 +1,44 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao.heart; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + + +/** + * 活动信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-07-19 + */ +@Mapper +public interface ActInfoDao{ + /** + * @return java.util.List> + * @param customerId + * @param monthId + * @author yinzuomei + * @description 查询这个月,各个网格举办的活动次数 活动状态已结束并且实际结束时间在评价周期内的 + * @Date 2020/9/21 10:41 + **/ + List> selectActGroupByGridId(@Param("customerId") String customerId, @Param("monthId") String monthId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactIndexServiceAbilityGridMonthlyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactIndexServiceAbilityGridMonthlyService.java index 793af948e6..a17d702326 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactIndexServiceAbilityGridMonthlyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactIndexServiceAbilityGridMonthlyService.java @@ -1,5 +1,9 @@ package com.epmet.service.evaluationindex.extract; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyEntity; + +import java.util.List; + /** * 服务能力-网格相关事实表 * @@ -7,5 +11,21 @@ package com.epmet.service.evaluationindex.extract; * @since v1.0.0 2020-09-19 */ public interface FactIndexServiceAbilityGridMonthlyService{ + /** + * @return java.util.List + * @param customerId + * @author yinzuomei + * @description 查询出所有的网格,初始化好 服务能力-网格相关事实表 各个指标值赋值为0 + * @Date 2020/9/21 9:38 + **/ + List initAllGridList(String customerId); + /** + * @return void + * @param list + * @author yinzuomei + * @description 批量插入网格相关-服务能力指标表 + * @Date 2020/9/21 10:05 + **/ + void insertBatchEntity(List list); } \ No newline at end of file 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 index 4c930bec8a..0b64d285fa 100644 --- 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 @@ -132,7 +132,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { //4、分批插入批量插入 List> partition = ListUtils.partition(indexPartyAblityCpcList, IndexCalConstant.INSERT_SIZE); partition.forEach(list -> { - this.FactIndexPartyAblityCpcMonthlyEntity(list); + this.saveFactIndexPartyAblityCpcMonthlyEntity(list); }); } @@ -428,7 +428,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2020/9/18 10:27 **/ @DataSource(value = DataSourceConstant.EVALUATION_INDEX) - private void FactIndexPartyAblityCpcMonthlyEntity(List list) { + private void saveFactIndexPartyAblityCpcMonthlyEntity(List list) { factIndexPartyAblityCpcMonthlyDao.insertBatchEntity(list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java index 9fea4c2476..2124f6e6cc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java @@ -1,19 +1,27 @@ 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.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.DataSourceConstant; import com.epmet.constant.ExtractConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.constant.ProjectEvaluateConstant; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao; +import com.epmet.dao.heart.ActInfoDao; import com.epmet.dto.extract.form.GovernAbilityGridMonthlyFormDTO; import com.epmet.dto.extract.form.GridIssueCountResultDTO; import com.epmet.dto.extract.form.PartyAbilityGridMonthlyFormDTO; import com.epmet.dto.extract.result.*; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyEntity; import com.epmet.service.evaluationindex.extract.*; import com.epmet.service.stats.FactArticlePublishedGridDailyService; import com.epmet.service.stats.user.FactRegUserGridMonthlyService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -56,7 +64,12 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { private FactArticlePublishedGridDailyService articlePublishedGridDailyService; @Autowired private GroupExtractService groupExtractService; - + @Autowired + private FactIndexServiceAbilityGridMonthlyService factIndexServiceAbilityGridMonthlyService; + @Autowired + private FactIndexServiceAblityGridMonthlyDao factIndexServiceAblityGridMonthlyDao; + @Autowired + private ActInfoDao actInfoDao; /** * @Description 计算网格指标党建能力 * @param customerId @@ -319,7 +332,86 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { */ @Override public Boolean calGridIndexServiceAbility(String customerId, String monthId) { - return null; + //1、构造好初始数据,各指标赋值0 + List entityList=factIndexServiceAbilityGridMonthlyService.initAllGridList(customerId); + if(CollectionUtils.isEmpty(entityList)){ + log.info("screen_customer_grid do not any records"); + return true; + } + String quarterId= DateUtils.getQuarterId(monthId); + String yearId=DateUtils.getYearId(monthId); + //各个网格这个月举办的活动 + Map activityCountMap=calActivityCountMap(customerId,monthId); + //2、遍历网格,赋值每个网格指标 + for(FactIndexServiceAblityGridMonthlyEntity entity:entityList){ + entity.setMonthId(monthId); + entity.setQuarterId(quarterId); + entity.setYearId(yearId); + //网格活动组织次数 爱心活动 + if(activityCountMap.containsKey(entity.getGridId())){ + entity.setActivityCount(activityCountMap.get(entity.getGridId())); + } + //网格志愿者占比 todo +// entity.setVolunteerRatio(); + //网格党员志愿者率 todo +// entity.setPartyVolunteerRatio(); + } + //3、批量删 + deleteBatchIndexServiceAblityGridMonthly(customerId,monthId); + //4、批量增 + List> partition = ListUtils.partition(entityList, IndexCalConstant.INSERT_SIZE); + partition.forEach(list -> { + this.saveFactIndexServiceAblityGridMonthlyEntity(list); + }); + return true; + } + + /** + * @return java.util.Map + * @param customerId + * @param monthId + * @author yinzuomei + * @description 网格活动组织次数 爱心活动 值得是: 活动状态已结束并且实际结束时间在评价周期内的 + * @Date 2020/9/21 10:23 + **/ + @DataSource(DataSourceConstant.EPMET_HEART) + private Map calActivityCountMap(String customerId, String monthId) { + List> mapList = actInfoDao.selectActGroupByGridId(customerId, monthId); + Map resultMap = new HashMap<>(); + for (Map map : mapList) { + for (Map.Entry m : map.entrySet()) { + resultMap.put(m.getKey(), m.getValue()); + } + } + return resultMap; + } + + /** + * @return void + * @param customerId + * @param monthId + * @author yinzuomei + * @description 批量删除网格相关-服务能力指标表 + * @Date 2020/9/21 10:16 + **/ + @DataSource(DataSourceConstant.EVALUATION_INDEX) + private void deleteBatchIndexServiceAblityGridMonthly(String customerId, String monthId) { + int deleteNum; + do { + deleteNum = factIndexServiceAblityGridMonthlyDao.deleteFactIndexServiceAblityGridMonthly(customerId, monthId); + } while (deleteNum > NumConstant.ZERO); + } + + /** + * @param list + * @return void + * @author yinzuomei + * @description 批量插入网格相关-服务能力指标表 + * @Date 2020/9/21 10:04 + **/ + @DataSource(DataSourceConstant.EVALUATION_INDEX) + private void saveFactIndexServiceAblityGridMonthlyEntity(List list) { + factIndexServiceAbilityGridMonthlyService.insertBatchEntity(list); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactIndexServiceAbilityGridMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactIndexServiceAbilityGridMonthlyServiceImpl.java index 3d5e2019e2..7bbf688492 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactIndexServiceAbilityGridMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactIndexServiceAbilityGridMonthlyServiceImpl.java @@ -2,10 +2,15 @@ package com.epmet.service.evaluationindex.extract.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyEntity; import com.epmet.service.evaluationindex.extract.FactIndexServiceAbilityGridMonthlyService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * 服务能力-网格相关事实表 * @@ -16,5 +21,30 @@ import org.springframework.stereotype.Service; @Slf4j @DataSource(DataSourceConstant.EVALUATION_INDEX) public class FactIndexServiceAbilityGridMonthlyServiceImpl implements FactIndexServiceAbilityGridMonthlyService { + @Autowired + private FactIndexServiceAblityGridMonthlyDao baseDao; + + /** + * @param customerId + * @return java.util.List + * @author yinzuomei + * @description 查询出所有的网格,初始化好 服务能力-网格相关事实表 各个指标值赋值为0 + * @Date 2020/9/21 9:38 + **/ + @Override + public List initAllGridList(String customerId) { + return baseDao.initAllGridList(customerId); + } + /** + * @param list + * @return void + * @author yinzuomei + * @description 批量插入网格相关-服务能力指标表 + * @Date 2020/9/21 10:05 + **/ + @Override + public void insertBatchEntity(List list) { + baseDao.insertBatchEntity(list); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.xml index f3ec6462f2..2a4d8a7039 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyDao.xml @@ -132,4 +132,66 @@ AND m.CUSTOMER_ID =#{customerId} AND m.MONTH_ID =#{monthId} + + + + + + + insert into fact_index_service_ablity_grid_monthly + ( + ID, + CUSTOMER_ID, + AGENCY_ID, + GRID_ID, + MONTH_ID, + QUARTER_ID, + YEAR_ID, + ACTIVITY_COUNT, + VOLUNTEER_RATIO, + PARTY_VOLUNTEER_RATIO, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME + ) values + + ( + (SELECT REPLACE(UUID(), '-', '') AS id), + #{item.customerId}, + #{item.agencyId}, + #{item.gridId}, + #{item.monthId}, + #{item.quarterId}, + #{item.yearId}, + #{item.activityCount}, + #{item.volunteerRatio}, + #{item.partyVolunteerRatio}, + 0, + 0, + 'APP_USER', + now(), + 'APP_USER', + now() + ) + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml new file mode 100644 index 0000000000..fafa780590 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/ActInfoDao.xml @@ -0,0 +1,21 @@ + + + + + + +