21 changed files with 595 additions and 2 deletions
@ -0,0 +1,26 @@ |
|||||
|
package com.epmet.dto.screen.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 大屏中央区数据写入传参DTO |
||||
|
* @ClassName ScreenCentralZoneDataFormDTO |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-09-24 10:02 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ScreenCentralZoneDataFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -6621150245370746092L; |
||||
|
|
||||
|
/** |
||||
|
* 客户Id |
||||
|
* */ |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 时间维度 不一定是dateId 需要根据其格式进行判断维度的类型 |
||||
|
* */ |
||||
|
private String dateId; |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package com.epmet.service.evaluationindex.extract.toscreen; |
||||
|
|
||||
|
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; |
||||
|
|
||||
|
/** |
||||
|
* 大屏中央区数据写入 |
||||
|
* */ |
||||
|
|
||||
|
public interface ScreenCentralZoneDataAbsorptionService { |
||||
|
|
||||
|
/** |
||||
|
* @Description 中央区数据写入 |
||||
|
* @param param |
||||
|
* @return |
||||
|
* @author wangc |
||||
|
* @date 2020.09.24 10:41 |
||||
|
**/ |
||||
|
void centralZoneDataHub(ScreenCentralZoneDataFormDTO param); |
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
package com.epmet.service.evaluationindex.extract.toscreen.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.NumConstant; |
||||
|
import com.epmet.commons.tools.utils.DateUtils; |
||||
|
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; |
||||
|
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; |
||||
|
import com.epmet.service.evaluationindex.extract.toscreen.ScreenCentralZoneDataAbsorptionService; |
||||
|
import com.epmet.service.evaluationindex.screen.ScreenUserTotalDataService; |
||||
|
import com.epmet.service.stats.ScreenCentralZoneDataExtractService; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @ClassName ScreenCentralZoneDataAbsorptionServiceImpl |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-09-24 10:42 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class ScreenCentralZoneDataAbsorptionServiceImpl implements ScreenCentralZoneDataAbsorptionService { |
||||
|
|
||||
|
@Autowired |
||||
|
private ScreenCentralZoneDataExtractService screenCentralZoneDataExtractService; |
||||
|
@Autowired |
||||
|
private ScreenUserTotalDataService screenUserTotalDataService; |
||||
|
|
||||
|
/** |
||||
|
* @Description 中央区数据写入 |
||||
|
* @param param |
||||
|
* @return |
||||
|
* @author wangc |
||||
|
* @date 2020.09.24 10:41 |
||||
|
**/ |
||||
|
@Override |
||||
|
public void centralZoneDataHub(ScreenCentralZoneDataFormDTO param) { |
||||
|
if(StringUtils.isBlank(param.getDateId())){ |
||||
|
//默认前一天
|
||||
|
param.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); |
||||
|
} |
||||
|
List<ScreenUserTotalDataEntity> dataList = screenCentralZoneDataExtractService.extractCentralZoneData(param.getCustomerId(),param.getDateId()); |
||||
|
|
||||
|
screenUserTotalDataService.dataClean(dataList,param.getCustomerId()); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package com.epmet.service.stats; |
||||
|
|
||||
|
import com.epmet.entity.evaluationindex.screen.ScreenUserTotalDataEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 大屏中央区数据抽取(form : date-statistical) |
||||
|
* */ |
||||
|
public interface ScreenCentralZoneDataExtractService { |
||||
|
|
||||
|
/** |
||||
|
* @Description 抽取中央区数据 |
||||
|
* @param customerId |
||||
|
* @param dimId |
||||
|
* @return |
||||
|
* @author wangc |
||||
|
* @date 2020.09.24 11:13 |
||||
|
**/ |
||||
|
List<ScreenUserTotalDataEntity> extractCentralZoneData(String customerId,String dimId); |
||||
|
|
||||
|
} |
||||
@ -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; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue