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 aa240d30aa..082fc28114 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,20 +1,26 @@
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.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.springframework.beans.BeanUtils;
+import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -58,6 +64,12 @@ public class CalGridIndexServiceImpl implements CalGridIndexService {
@Autowired
private FactOriginTopicLogDailyService topicLogService;
+ @Autowired
+ private FactIndexServiceAbilityGridMonthlyService factIndexServiceAbilityGridMonthlyService;
+ @Autowired
+ private FactIndexServiceAblityGridMonthlyDao factIndexServiceAblityGridMonthlyDao;
+ @Autowired
+ private ActInfoDao actInfoDao;
/**
* @Description 计算网格指标党建能力
* @param customerId
@@ -125,7 +137,8 @@ public class CalGridIndexServiceImpl implements CalGridIndexService {
if (!CollectionUtils.isEmpty(gridUserCountList)){
gridUserCountList.forEach(count -> {
if (r.getGridId().equals(count.getGridId())){
- BeanUtils.copyProperties(count,r);
+ r.setUserCount(count.getUserCount());
+ r.setPartyCount(count.getPartyCount());
}
});
}
@@ -307,7 +320,8 @@ public class CalGridIndexServiceImpl implements CalGridIndexService {
if (!CollectionUtils.isEmpty(gridIssueTotalList)) {
gridIssueTotalList.forEach(total -> {
if (r.getGridId().equals(total.getGridId())) {
- BeanUtils.copyProperties(total, r);
+ r.setIssueTotal(total.getIssueTotal());
+ r.setAvgIssueCount(total.getAvgIssueCount());
}
});
}
@@ -362,7 +376,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/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
index 7e0ac4e99d..ccb02b714f 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
@@ -175,6 +175,11 @@ dynamic:
url: @datasource.druid.partyMember.url@
username: @datasource.druid.partyMember.username@
password: @datasource.druid.partyMember.password@
+ epmetHeart:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: @datasource.druid.epmetHeart.url@
+ username: @datasource.druid.epmetHeart.username@
+ password: @datasource.druid.epmetHeart.password@
thread:
# 线程池配置
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}
+
+
+
+ SELECT
+ scg.CUSTOMER_ID,
+ scg.PARENT_AGENCY_ID AS agencyId,
+ scg.GRID_ID,
+ null as MONTH_ID,
+ NULL AS QUARTER_ID,
+ null as YEAR_ID,
+ 0 AS ACTIVITY_COUNT,
+ 0 AS VOLUNTEER_RATIO,
+ 0 AS PARTY_VOLUNTEER_RATIO
+ FROM
+ screen_customer_grid scg
+ WHERE
+ DEL_FLAG = 0
+ AND CUSTOMER_ID = #{customerId}
+
+
+
+
+ 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 @@
+
+
+
+
+
+
+ SELECT
+ ai.SPONSOR_ID,
+ count( 1 ) AS totalAct
+ FROM
+ act_info ai
+ WHERE
+ ai.DEL_FLAG = '0'
+ AND ai.ACT_STATUS = 'finished'
+ AND ai.SPONSOR_TYPE = 'grid'
+ and ai.CUSTOMER_ID=#{customerId}
+ AND DATE_FORMAT(ai.ACTUAL_END_TIME,'%Y%m') = #{monthId}
+ GROUP BY
+ ai.SPONSOR_ID
+
+