|
|
@ -4,13 +4,22 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.dto.ProjectCategoryDTO; |
|
|
|
import com.epmet.dto.ProjectDTO; |
|
|
|
import com.epmet.dto.org.GridInfoDTO; |
|
|
|
import com.epmet.dto.project.result.ProjectLatestOperationResultDTO; |
|
|
|
import com.epmet.dto.screen.form.ProjectSourceMapFormDTO; |
|
|
|
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; |
|
|
|
import com.epmet.dto.topic.result.ResiTopicAndImgResultDTO; |
|
|
|
import com.epmet.entity.evaluationindex.extract.FactOriginProjectMainDailyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.extract.FactOriginProjectOrgPeriodDailyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyDataEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyImgDataEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; |
|
|
|
import com.epmet.entity.issue.IssueProjectCategoryDictEntity; |
|
|
|
import com.epmet.entity.stats.DimAgencyEntity; |
|
|
|
import com.epmet.service.Issue.IssueProjectCategoryDictService; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectMainDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.toscreen.ScreenGrassrootsGovernDataAbsorptionService; |
|
|
|
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; |
|
|
@ -20,6 +29,7 @@ import com.epmet.service.org.CustomerGridService; |
|
|
|
import com.epmet.service.point.UserPointService; |
|
|
|
import com.epmet.service.project.ProjectProcessService; |
|
|
|
import com.epmet.service.project.ProjectService; |
|
|
|
import com.epmet.service.stats.DimAgencyService; |
|
|
|
import com.epmet.service.topic.TopicService; |
|
|
|
import com.epmet.service.user.UserService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -49,6 +59,8 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr |
|
|
|
@Autowired |
|
|
|
private CustomerGridService customerGridService; |
|
|
|
@Autowired |
|
|
|
private DimAgencyService dimAgencyService; |
|
|
|
@Autowired |
|
|
|
private UserPointService userPointService; |
|
|
|
@Autowired |
|
|
|
private CpcIndexCalculateService cpcIndexCalculateService; |
|
|
@ -64,6 +76,8 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr |
|
|
|
private TopicService topicService; |
|
|
|
@Autowired |
|
|
|
private ProjectService projectService; |
|
|
|
@Autowired |
|
|
|
private IssueProjectCategoryDictService issueProjectCategoryDictService; |
|
|
|
/** |
|
|
|
* @Description 用户积分、党员分值数据中转站 |
|
|
|
* @param param |
|
|
@ -137,7 +151,9 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr |
|
|
|
public void difficultyDataHub(ScreenCentralZoneDataFormDTO param) { |
|
|
|
//查询数据
|
|
|
|
List<ScreenDifficultyDataEntity> difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(),projectService.getOvertimeProjectByParameter(param.getCustomerId())); |
|
|
|
if(CollectionUtils.isEmpty(difficulties)) return; |
|
|
|
if(CollectionUtils.isEmpty(difficulties)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//2.查询出客户下网格的相关信息
|
|
|
|
List<GridInfoDTO> gridList = customerGridService.queryGridInfoList(param.getCustomerId()); |
|
|
@ -157,7 +173,10 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr |
|
|
|
Map<String, ProjectLatestOperationResultDTO> latestOperationMap = projectProcessService.getLatestOperation(projectIds,param.getCustomerId()); |
|
|
|
//图片
|
|
|
|
List<ProjectSourceMapFormDTO> projectSourceMap = difficulties.stream().map(diff->{ |
|
|
|
ProjectSourceMapFormDTO map = new ProjectSourceMapFormDTO();map.setProjectId(diff.getEventId());map.setSourceId(diff.getEventImgUrl());return map; |
|
|
|
ProjectSourceMapFormDTO map = new ProjectSourceMapFormDTO(); |
|
|
|
map.setProjectId(diff.getEventId()); |
|
|
|
map.setSourceId(diff.getEventImgUrl()); |
|
|
|
return map; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
//factOriginProjectMainDailyService.getNewProject(param.getCustomerId(),projectIds);
|
|
|
|
|
|
|
@ -194,4 +213,185 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr |
|
|
|
screenDifficultyDataService.dataClean(param.getCustomerId(),difficulties,imgList); |
|
|
|
log.info("【大屏数据抽取-难点赌点执行完毕】 客户Id{} 难点赌点数据{}",param.getCustomerId(),JSON.toJSONString(difficulties)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean difficultyDataExtract(ScreenCentralZoneDataFormDTO param) { |
|
|
|
//TODO
|
|
|
|
//1.根据客户Id 获取所有项目数据
|
|
|
|
List<FactOriginProjectMainDailyEntity> difficultyBaseList = factOriginProjectMainDailyService.getProjectForDiff(param); |
|
|
|
if (CollectionUtils.isEmpty(difficultyBaseList)){ |
|
|
|
log.warn("difficultyDataExtract customerId:{} have any project",param.getCustomerId()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
//获取业务库项目标题
|
|
|
|
List<ProjectDTO> bizProjectInfoList = projectService.getProjectInfo(param.getCustomerId(), null); |
|
|
|
if (CollectionUtils.isEmpty(bizProjectInfoList)){ |
|
|
|
log.warn("difficultyDataExtract customerId:{} have any project",param.getCustomerId()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
Map<String, ProjectDTO> bizProjectInfoMap = bizProjectInfoList.stream().collect(Collectors.toMap(ProjectDTO::getId, o -> o, (o1, o2) -> o1)); |
|
|
|
//获取agency维度
|
|
|
|
List<DimAgencyEntity> agencyList = dimAgencyService.getAgencyListByCustomerId(param.getCustomerId()); |
|
|
|
Map<String, DimAgencyEntity> agencyMap = agencyList.stream().collect(Collectors.toMap(DimAgencyEntity::getId, o -> o, (o1, o2) -> o1)); |
|
|
|
//获取grid维度
|
|
|
|
List<GridInfoDTO> gridList = customerGridService.queryGridInfoList(param.getCustomerId()); |
|
|
|
Map<String, GridInfoDTO> gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO::getGridId, o -> o, (o1, o2) -> o1)); |
|
|
|
|
|
|
|
//获取客户下所有项目分类
|
|
|
|
List<IssueProjectCategoryDictEntity> categoryList = issueProjectCategoryDictService.getAllByCId(param.getCustomerId()); |
|
|
|
|
|
|
|
//项目分类数据 todo 暂时查询所有
|
|
|
|
List<ProjectCategoryDTO> projectCategoryData = projectService.getProjectCategoryData(param.getCustomerId(), null); |
|
|
|
//key projectId:categoryCode Set
|
|
|
|
Map<String, Set<String>> projectCategoryMap = projectCategoryData.stream() |
|
|
|
.collect(Collectors.groupingBy(ProjectCategoryDTO::getProjectId, Collectors.mapping(ProjectCategoryDTO::getCategoryCode, Collectors.toSet()))); |
|
|
|
|
|
|
|
//2.获取项目的所有节点耗时数据
|
|
|
|
List<FactOriginProjectOrgPeriodDailyEntity> projectPeriodList = factOriginProjectMainDailyService.getProjectPeriod(param); |
|
|
|
Map<String,Integer> orgCountMap = new HashMap<>(); |
|
|
|
Map<String,Integer> handleCountMap = new HashMap<>(); |
|
|
|
projectPeriodList.forEach(period->{ |
|
|
|
Integer orgCount = orgCountMap.get(period.getProjectId()); |
|
|
|
if (orgCount == null){ |
|
|
|
orgCount = 0; |
|
|
|
}else{ |
|
|
|
++orgCount; |
|
|
|
} |
|
|
|
orgCountMap.put(period.getProjectId(),orgCount); |
|
|
|
Integer handleCount = handleCountMap.get(period.getProjectId()); |
|
|
|
if (handleCount == null){ |
|
|
|
handleCount = 0; |
|
|
|
}else{ |
|
|
|
++handleCount; |
|
|
|
} |
|
|
|
handleCountMap.put(period.getProjectId(),handleCount); |
|
|
|
}); |
|
|
|
List<ScreenDifficultyDataEntity> diffList = new ArrayList<>(); |
|
|
|
for (FactOriginProjectMainDailyEntity project : difficultyBaseList) { |
|
|
|
if (agencyMap.get(project.getAgencyId()) == null || bizProjectInfoMap.get(project.getId()) == null) { |
|
|
|
log.error("未获取到相关的项目信息或者项目的所属组织信息"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
ScreenDifficultyDataEntity diffEntity = buildBaseDiffEntity(project, agencyMap, gridMap, bizProjectInfoMap); |
|
|
|
Integer regCount = orgCountMap.get(project.getId()); |
|
|
|
if (regCount != null){ |
|
|
|
diffEntity.setEventReOrg(regCount); |
|
|
|
} |
|
|
|
Integer handleOrgCount = handleCountMap.get(project.getId()); |
|
|
|
if (handleOrgCount != null){ |
|
|
|
diffEntity.setEventHandledCount(handleOrgCount); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
diffEntity.setDataEndTime(param.getDateId()); |
|
|
|
setCategoryInfo(diffEntity, project.getId(),categoryList,projectCategoryMap); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(project.getTopicId())){ |
|
|
|
//获取图片及话题内容
|
|
|
|
ResiTopicAndImgResultDTO topicInfo = topicService.getTopicAndImgs(project.getTopicId(),"image"); |
|
|
|
if (topicInfo != null){ |
|
|
|
diffEntity.setEventImgUrl(topicInfo.getTopicImgList().get(NumConstant.ZERO).getAttachmentUrl()); |
|
|
|
diffEntity.setEventContent(topicInfo.getTopicContent()); |
|
|
|
} |
|
|
|
} |
|
|
|
diffList.add(diffEntity); |
|
|
|
log.info("========:"+JSON.toJSONString(diffList)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3.获取项目的最后操作记录
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private void setCategoryInfo(ScreenDifficultyDataEntity diffEntity, String projectId, List<IssueProjectCategoryDictEntity> categoryList, Map<String, Set<String>> projectCategoryMap) { |
|
|
|
Set<String> categorySet = projectCategoryMap.get(projectId); |
|
|
|
if (CollectionUtils.isEmpty(categorySet)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
projectCategoryMap.forEach((k,v) ->{ |
|
|
|
List<IssueProjectCategoryDictEntity> childCategory = new ArrayList<>(); |
|
|
|
v.forEach(categoryCode-> getParentNode(childCategory,categoryList,categoryCode)); |
|
|
|
String categoryCodes = childCategory.stream().map(IssueProjectCategoryDictEntity::getCategoryCode).sorted(Comparator.reverseOrder()).collect(Collectors.joining(StrConstant.COMMA)); |
|
|
|
String categoryNames = childCategory.stream().map(IssueProjectCategoryDictEntity::getCategoryName).sorted(Comparator.reverseOrder()).collect(Collectors.joining(StrConstant.COMMA)); |
|
|
|
diffEntity.setEventCategoryCode(categoryCodes); |
|
|
|
diffEntity.setEventCategoryName(categoryNames); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private ScreenDifficultyDataEntity buildBaseDiffEntity(FactOriginProjectMainDailyEntity project, Map<String, DimAgencyEntity> agencyMap, |
|
|
|
Map<String, GridInfoDTO> gridMap, Map<String, ProjectDTO> bizProjectInfoMap) { |
|
|
|
ProjectDTO projectDTO = bizProjectInfoMap.get(project.getId()); |
|
|
|
ScreenDifficultyDataEntity diff = new ScreenDifficultyDataEntity(); |
|
|
|
diff.setCustomerId(project.getCustomerId()); |
|
|
|
//大屏的是逗号隔开的
|
|
|
|
String allPIds = project.getPids().replaceAll(StrConstant.COLON,StrConstant.COMMA); |
|
|
|
DimAgencyEntity agencyInfoDTO = agencyMap.get(project.getAgencyId()); |
|
|
|
if (StringUtils.isBlank(project.getGridId())){ |
|
|
|
diff.setOrgType("agency"); |
|
|
|
diff.setOrgId(project.getAgencyId()); |
|
|
|
diff.setParentId(project.getPid()); |
|
|
|
diff.setAllParentIds(allPIds.replace(StrConstant.COMMA+project.getAgencyId(),StrConstant.EPMETY_STR)); |
|
|
|
diff.setOrgName(agencyInfoDTO.getAgencyName()); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(agencyInfoDTO.getAllParentName())){ |
|
|
|
diff.setEventSource(agencyInfoDTO.getAllParentName().concat(StrConstant.HYPHEN.concat(diff.getOrgName()))); |
|
|
|
}else{ |
|
|
|
diff.setEventSource(agencyInfoDTO.getAgencyName()); |
|
|
|
} |
|
|
|
//如果是组织的则 设置背景为内容
|
|
|
|
diff.setEventContent(projectDTO.getBackGround()); |
|
|
|
}else{ |
|
|
|
diff.setOrgType("grid"); |
|
|
|
diff.setOrgId(project.getGridId()); |
|
|
|
diff.setParentId(project.getAgencyId()); |
|
|
|
//所有上级id 即包含agencyId在内的所有pids
|
|
|
|
diff.setAllParentIds(allPIds); |
|
|
|
GridInfoDTO gridInfoDTO = gridMap.get(project.getGridId()); |
|
|
|
diff.setOrgName(gridInfoDTO.getGridName()); |
|
|
|
String agencyAndGridName = agencyInfoDTO.getAgencyName().concat(StrConstant.HYPHEN.concat(diff.getOrgName())); |
|
|
|
//todo 市北区的 allParentname 为什么为空
|
|
|
|
//if (!project.getPid().equals(NumConstant.ZERO_STR)){
|
|
|
|
if (StringUtils.isNotBlank(agencyInfoDTO.getAllParentName())){ |
|
|
|
diff.setEventSource(agencyInfoDTO.getAllParentName().concat(StrConstant.HYPHEN).concat(agencyAndGridName)); |
|
|
|
}else{ |
|
|
|
diff.setEventSource(agencyAndGridName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
diff.setEventId(project.getId()); |
|
|
|
String projectStatus = project.getProjectStatus(); |
|
|
|
diff.setEventStatusCode(projectStatus); |
|
|
|
if (ProjectConstant.PENDING.equals(projectStatus)){ |
|
|
|
diff.setEventStatusDesc("处理中"); |
|
|
|
//项目耗时 当前时间-项目创建时间
|
|
|
|
diff.setEventCostTime((int) ((System.currentTimeMillis()-projectDTO.getCreatedTime().getTime())/1000/60)); |
|
|
|
}else{ |
|
|
|
diff.setEventStatusDesc("已结案"); |
|
|
|
//项目耗时 更新时间-项目创建时间
|
|
|
|
diff.setEventCostTime((int) ((projectDTO.getUpdatedTime().getTime() - projectDTO.getCreatedTime().getTime())/1000/60)); |
|
|
|
} |
|
|
|
//暂时不放内容 用不到
|
|
|
|
diff.setLatestOperateDesc(""); |
|
|
|
|
|
|
|
return diff; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 递归查询父节点 |
|
|
|
* @param childCategory |
|
|
|
* @param categoryList |
|
|
|
* @param categoryCode |
|
|
|
*/ |
|
|
|
private void getParentNode(List<IssueProjectCategoryDictEntity> childCategory, List<IssueProjectCategoryDictEntity> categoryList, String categoryCode) { |
|
|
|
categoryList.stream() |
|
|
|
.filter(item -> Objects.nonNull(categoryCode) && Objects.equals(categoryCode, item.getCategoryCode())) |
|
|
|
.forEach(menu -> { |
|
|
|
getParentNode(childCategory, categoryList, menu.getParentCategoryCode()); |
|
|
|
childCategory.add(menu); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|