|
|
|
@ -0,0 +1,164 @@ |
|
|
|
package com.epmet.service.stats.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.dao.stats.*; |
|
|
|
import com.epmet.dao.stats.topic.FactTopicTotalAgencyDailyDao; |
|
|
|
import com.epmet.dao.stats.topic.FactTopicTotalGridDailyDao; |
|
|
|
|
|
|
|
|
|
|
|
import com.epmet.dao.stats.user.FactParticipationUserGridDailyDao; |
|
|
|
|
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; |
|
|
|
import com.epmet.service.stats.ScreenCentralZoneDataExtractService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 大屏中央区数据抽取(form : date-statistical) |
|
|
|
* @ClassName ScreenCentralZoneDataExtractServiceImpl |
|
|
|
* @Auth wangc |
|
|
|
* @Date 2020-09-24 11:15 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@DataSource(DataSourceConstant.STATS) |
|
|
|
public class ScreenCentralZoneDataExtractServiceImpl implements ScreenCentralZoneDataExtractService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FactParticipationUserGridDailyDao factParticipationUserGridDailyDao; |
|
|
|
@Autowired |
|
|
|
private FactGroupGridDailyDao factGroupGridDailyDao; |
|
|
|
@Autowired |
|
|
|
private FactTopicTotalGridDailyDao factTopicTotalGridDailyDao; |
|
|
|
@Autowired |
|
|
|
private FactIssueGridDailyDao factIssueGridDailyDao; |
|
|
|
@Autowired |
|
|
|
private FactAgencyProjectDailyDao factAgencyProjectDailyDao; |
|
|
|
|
|
|
|
|
|
|
|
private final String ORG_LEVEL_AGENCY = "agency"; |
|
|
|
private final String ORG_LEVEL_GRID = "grid"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 抽取中央区数据 |
|
|
|
* @param customerId |
|
|
|
* @param dimId |
|
|
|
* @return |
|
|
|
* @author wangc |
|
|
|
* @date 2020.09.24 11:13 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<ScreenUserTotalDataEntity> extractCentralZoneData(String customerId, String dimId) { |
|
|
|
|
|
|
|
//1.查询用户与党员数据,判断dimId是否为昨天,如果根据这个dimId没有查询出结果,则取前天的数据
|
|
|
|
//如果还是查不出数据,继续向下执行,这部分数据设置默认值
|
|
|
|
List<ScreenUserTotalDataEntity> result = |
|
|
|
factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(result)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
result = factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
if(null == result) result = new LinkedList<>(); |
|
|
|
} |
|
|
|
List<ScreenUserTotalDataEntity> gridUserResult = |
|
|
|
factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(gridUserResult)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
gridUserResult = factParticipationUserGridDailyDao.selectUserAndPartymemberByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!CollectionUtils.isEmpty(gridUserResult)){ |
|
|
|
result.addAll(gridUserResult); |
|
|
|
} |
|
|
|
|
|
|
|
//2.组
|
|
|
|
List<ScreenUserTotalDataEntity> agencyGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(agencyGroup)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
agencyGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScreenUserTotalDataEntity> gridGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(gridGroup)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
gridGroup = factGroupGridDailyDao.selectGroupCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Integer> groupMap = agencyGroup.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getGroupTotal)); |
|
|
|
groupMap.putAll(gridGroup.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getGroupTotal))); |
|
|
|
|
|
|
|
|
|
|
|
//3.话题
|
|
|
|
List<ScreenUserTotalDataEntity> agencyTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(agencyTopic)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
agencyTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScreenUserTotalDataEntity> gridTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(gridTopic)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
gridTopic = factTopicTotalGridDailyDao.selectTopicCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Integer> topicMap = agencyTopic.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getTopicTotal)); |
|
|
|
topicMap.putAll(gridTopic.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getTopicTotal))); |
|
|
|
|
|
|
|
//4.议题
|
|
|
|
List<ScreenUserTotalDataEntity> agencyIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(agencyIssue)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
agencyIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScreenUserTotalDataEntity> gridIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(gridIssue)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
gridIssue = factIssueGridDailyDao.selectIssueCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Integer> issueMap = agencyIssue.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal)); |
|
|
|
issueMap.putAll(gridIssue.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal))); |
|
|
|
|
|
|
|
//5.项目
|
|
|
|
List<ScreenUserTotalDataEntity> agencyProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(agencyProject)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
agencyProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_AGENCY,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScreenUserTotalDataEntity> gridProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_GRID,customerId,dimId); |
|
|
|
if(CollectionUtils.isEmpty(gridProject)){ |
|
|
|
if(DateUtils.getBeforeNDay(NumConstant.ONE).equals(dimId)){ |
|
|
|
gridProject = factAgencyProjectDailyDao.selectProjectCountByOrgLevel(ORG_LEVEL_GRID,customerId,DateUtils.getBeforeNDay(NumConstant.TWO)); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Integer> projectMap = agencyProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal)); |
|
|
|
projectMap.putAll(gridProject.stream().collect(Collectors.toMap(ScreenUserTotalDataEntity::getOrgId,ScreenUserTotalDataEntity::getIssueTotal))); |
|
|
|
|
|
|
|
result.forEach(o -> { |
|
|
|
String orgId = o.getOrgId(); |
|
|
|
o.setGroupTotal(groupMap.get(orgId)); |
|
|
|
o.setTopicTotal(topicMap.get(orgId)); |
|
|
|
o.setIssueTotal(issueMap.get(orgId)); |
|
|
|
o.setProjectTotal(projectMap.get(orgId)); |
|
|
|
o.setDataEndTime(dimId); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |