Browse Source

难点堵点代码暂存-基本没问题了;还需要调整项目分类

dev_shibei_match
jianjun 5 years ago
parent
commit
2f5efbca71
  1. 195
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml
  3. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml

195
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java

@ -78,10 +78,11 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
private ProjectService projectService;
@Autowired
private IssueProjectCategoryDictService issueProjectCategoryDictService;
/**
* @Description 用户积分党员分值数据中转站
* @param param
* @return
* @Description 用户积分党员分值数据中转站
* @author wangc
* @date 2020.09.25 09:53
**/
@ -93,16 +94,16 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
//2.查询出客户下网格的相关信息
List<GridInfoDTO> gridList = customerGridService.queryGridInfoList(param.getCustomerId());
// list 转 map,以gridId为key,a = gridList,作为value,(o,n)->o 是遇到相同的gridId舍弃,(o,n)->n 是覆盖原来的gridId
Map<String,GridInfoDTO> gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO :: getGridId,a -> a,(o, n) -> o));
Map<String, GridInfoDTO> gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO::getGridId, a -> a, (o, n) -> o));
//3.查询出客户下用户的累计积分(累计值,没有时间概念,否则需要查询积分明细计算出评价周期末的得分)
Map<String,Integer> pointMap = userPointService.getUserPointMap(param.getCustomerId());
Map<String, Integer> pointMap = userPointService.getUserPointMap(param.getCustomerId());
//4.查询出客户下党员的分值
String dateId = param.getDateId();
if(StringUtils.isEmpty(dateId)){
if (StringUtils.isEmpty(dateId)) {
//如果没有传月份,则使用当前时间的上一个月
dateId = DateUtils.getBeforeNMonth(NumConstant.ONE);
}else{
} else {
String dateType = DateUtils.identifyTimeDimension(dateId);
if (StringUtils.isEmpty(dateType) || !StringUtils.equalsAny(dateType, "date", "month")) {
dateId = DateUtils.getBeforeNMonth(NumConstant.ONE);
@ -112,21 +113,21 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
}
final String finalDateId = dateId;
// 查询党员积分
Map<String, BigDecimal> scoreMap = cpcIndexCalculateService.getCpcScore(param.getCustomerId(),dateId);
Map<String, BigDecimal> scoreMap = cpcIndexCalculateService.getCpcScore(param.getCustomerId(), dateId);
//剔除垃圾数据
registeredUsers.removeIf(user -> null == gridMap.get(user.getGridId()));
//5.整合数据
if(!CollectionUtils.isEmpty(registeredUsers)){
if (!CollectionUtils.isEmpty(registeredUsers)) {
registeredUsers.forEach(user -> {
GridInfoDTO gridInfo = gridMap.get(user.getGridId());
if(null != gridInfo){
if (null != gridInfo) {
user.setGridName(gridInfo.getGridName());
user.setOrgId(gridInfo.getAgencyId());
user.setOrgName(gridInfo.getOrgName());
//原始数据Pid使用英文:隔开,大屏数据要求按照英文,隔开
user.setAllParentIds(gridInfo.getPids().replaceAll(StrConstant.COLON,StrConstant.COMMA));
user.setAllParentIds(gridInfo.getPids().replaceAll(StrConstant.COLON, StrConstant.COMMA));
}
Integer point = pointMap.get(user.getUserId());
BigDecimal score = scoreMap.get(user.getUserId());
@ -141,23 +142,23 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
}
/**
* @Description 难点赌点数据中转站
* @param param
* @return
* @Description 难点赌点数据中转站
* @author wangc
* @date 2020.09.25 10:00
**/
@Override
public void difficultyDataHub(ScreenCentralZoneDataFormDTO param) {
//查询数据
List<ScreenDifficultyDataEntity> difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(),projectService.getOvertimeProjectByParameter(param.getCustomerId()));
if(CollectionUtils.isEmpty(difficulties)) {
List<ScreenDifficultyDataEntity> difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(), projectService.getOvertimeProjectByParameter(param.getCustomerId()));
if (CollectionUtils.isEmpty(difficulties)) {
return;
}
//2.查询出客户下网格的相关信息
List<GridInfoDTO> gridList = customerGridService.queryGridInfoList(param.getCustomerId());
Map<String,GridInfoDTO> gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO :: getGridId,a -> a,(o, n) -> o));
Map<String, GridInfoDTO> gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO::getGridId, a -> a, (o, n) -> o));
//剔除垃圾数据(本次需要更新的数据集)
//for(Iterator<ScreenDifficultyDataEntity> iter = difficulties.iterator(); iter.hasNext();){
@ -166,13 +167,13 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
// iter.remove();
// }
//}
difficulties.removeIf( diff -> null == gridMap.get(diff.getOrgId()));
difficulties.removeIf(diff -> null == gridMap.get(diff.getOrgId()));
List<String> projectIds = difficulties.stream().map(ScreenDifficultyDataEntity :: getEventId).distinct().collect(Collectors.toList());
List<String> projectIds = difficulties.stream().map(ScreenDifficultyDataEntity::getEventId).distinct().collect(Collectors.toList());
//最近一次操作
Map<String, ProjectLatestOperationResultDTO> latestOperationMap = projectProcessService.getLatestOperation(projectIds,param.getCustomerId());
Map<String, ProjectLatestOperationResultDTO> latestOperationMap = projectProcessService.getLatestOperation(projectIds, param.getCustomerId());
//图片
List<ProjectSourceMapFormDTO> projectSourceMap = difficulties.stream().map(diff->{
List<ProjectSourceMapFormDTO> projectSourceMap = difficulties.stream().map(diff -> {
ProjectSourceMapFormDTO map = new ProjectSourceMapFormDTO();
map.setProjectId(diff.getEventId());
map.setSourceId(diff.getEventImgUrl());
@ -180,22 +181,22 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
}).collect(Collectors.toList());
//factOriginProjectMainDailyService.getNewProject(param.getCustomerId(),projectIds);
Map<String,List<ScreenDifficultyImgDataEntity>> imgMap = topicService.getTopicImgs(projectSourceMap);
Map<String, List<ScreenDifficultyImgDataEntity>> imgMap = topicService.getTopicImgs(projectSourceMap);
Map<String,String> contentMap = topicService.getTopicContent(projectSourceMap);
Map<String, String> contentMap = topicService.getTopicContent(projectSourceMap);
difficulties.forEach( diff -> {
difficulties.forEach(diff -> {
List<ScreenDifficultyImgDataEntity> figureList = CollectionUtils.isEmpty(imgMap) ? null : imgMap.get(diff.getEventId());
diff.setEventImgUrl(CollectionUtils.isEmpty(figureList) ? "" : figureList.get(NumConstant.ZERO).getEventImgUrl());
List<ScreenDifficultyImgDataEntity> figureList = CollectionUtils.isEmpty(imgMap) ? null : imgMap.get(diff.getEventId());
diff.setEventImgUrl(CollectionUtils.isEmpty(figureList) ? "" : figureList.get(NumConstant.ZERO).getEventImgUrl());
if(!CollectionUtils.isEmpty(contentMap)) {
if (!CollectionUtils.isEmpty(contentMap)) {
diff.setEventContent(contentMap.get(diff.getEventId()));
}
if(! CollectionUtils.isEmpty(latestOperationMap)){
if (!CollectionUtils.isEmpty(latestOperationMap)) {
ProjectLatestOperationResultDTO oper = latestOperationMap.get(diff.getEventId());
if(null != oper){
if (null != oper) {
diff.setLatestOperateDesc(oper.getOperationName());
diff.setEventTitle(oper.getTitle());
diff.setEventCostTime(oper.getCostTime());
@ -208,10 +209,10 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
imgMap.values().forEach(imgList::addAll);
//立案后会有 一个process 如果没有则说明是垃圾数据 如果有其他方式立项的项目则需要考虑下兼容
difficulties.removeIf( diff -> StringUtils.isBlank(diff.getLatestOperateDesc()));
difficulties.removeIf(diff -> StringUtils.isBlank(diff.getLatestOperateDesc()));
screenDifficultyDataService.dataClean(param.getCustomerId(),difficulties,imgList);
log.info("【大屏数据抽取-难点赌点执行完毕】 客户Id{} 难点赌点数据{}",param.getCustomerId(),JSON.toJSONString(difficulties));
screenDifficultyDataService.dataClean(param.getCustomerId(), difficulties, imgList);
log.info("【大屏数据抽取-难点赌点执行完毕】 客户Id{} 难点赌点数据{}", param.getCustomerId(), JSON.toJSONString(difficulties));
}
@Override
@ -219,14 +220,14 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
//TODO
//1.根据客户Id 获取所有项目数据
List<FactOriginProjectMainDailyEntity> difficultyBaseList = factOriginProjectMainDailyService.getProjectForDiff(param);
if (CollectionUtils.isEmpty(difficultyBaseList)){
log.warn("difficultyDataExtract customerId:{} have any project",param.getCustomerId());
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());
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));
@ -248,72 +249,115 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
//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;
//处理部门数去重(只要流转到就算)
Map<String, Set<String>> orgCountMap = new HashMap<>();
//被处理次数
Map<String, Integer> handleCountMap = new HashMap<>();
//已经结案的项目的结案时间
Set<String> valideProjectIdSet = new HashSet<>();
Map<String, Date> closeProjectDateMap = projectPeriodList.stream().filter(o -> ProjectConstant.CLOSE.equals(o.getOperation()))
.collect(Collectors.toMap(FactOriginProjectOrgPeriodDailyEntity::getProjectId, FactOriginProjectOrgPeriodDailyEntity::getHandledDate, (o1, o2) -> o1));
//超期项目阈值
Integer overtimeConfig = projectService.getOvertimeProjectByParameter(param.getCustomerId());
Map<String, Date> informDate = new HashMap<>();
projectPeriodList.forEach(period -> {
Set<String> orgCount = orgCountMap.get(period.getProjectId());
if (orgCount == null) {
orgCount = new HashSet<>();
}
orgCount.add(period.getOrgId());
orgCountMap.put(period.getProjectId(), orgCount);
if (ProjectConstant.RESOLVED.equals(period.getIsResolved())) {
Integer handleCount = handleCountMap.getOrDefault(period.getProjectId(), 0);
handleCountMap.put(period.getProjectId(), ++handleCount);
}
orgCountMap.put(period.getProjectId(),orgCount);
Integer handleCount = handleCountMap.get(period.getProjectId());
if (handleCount == null){
handleCount = 0;
}else{
++handleCount;
if ("82ac5292612538eaf5c598005b7910ba".equals(period.getProjectId())) {
System.out.println("项目结案时间" + closeProjectDateMap.get(period.getProjectId()));
}
//筛选出 项目的结案时间 未结案的为当前时间(结案只有一条记录)
if (period.getHandledDate() != null) {
if (period.getHandledDate().getTime() - period.getInformedDate().getTime() > overtimeConfig * 1000 * 60 * 60 * 24) {
valideProjectIdSet.add(period.getProjectId());
}
} else {
Date finishDate = closeProjectDateMap.getOrDefault(period.getProjectId(), new Date());
if (finishDate.getTime() - period.getInformedDate().getTime() > overtimeConfig * 1000 * 60 * 60 * 24) {
valideProjectIdSet.add(period.getProjectId());
}
}
handleCountMap.put(period.getProjectId(),handleCount);
});
List<ScreenDifficultyDataEntity> diffList = new ArrayList<>();
List<ScreenDifficultyImgDataEntity> imgDataEntities = new ArrayList<>();
for (FactOriginProjectMainDailyEntity project : difficultyBaseList) {
if (agencyMap.get(project.getAgencyId()) == null || bizProjectInfoMap.get(project.getId()) == null) {
log.error("未获取到相关的项目信息或者项目的所属组织信息");
continue;
}
//判断是否符合难点堵点条件
if (!valideProjectIdSet.contains(project.getId())) {
continue;
}
ScreenDifficultyDataEntity diffEntity = buildBaseDiffEntity(project, agencyMap, gridMap, bizProjectInfoMap);
Integer regCount = orgCountMap.get(project.getId());
if (regCount != null){
diffEntity.setEventReOrg(regCount);
Set<String> regCount = orgCountMap.get(project.getId());
if (regCount != null) {
diffEntity.setEventReOrg(regCount.size());
} else {
diffEntity.setEventReOrg(0);
}
Integer handleOrgCount = handleCountMap.get(project.getId());
if (handleOrgCount != null){
if (handleOrgCount != null) {
diffEntity.setEventHandledCount(handleOrgCount);
} else {
diffEntity.setEventHandledCount(0);
}
diffEntity.setDataEndTime(param.getDateId());
setCategoryInfo(diffEntity, project.getId(),categoryList,projectCategoryMap);
setCategoryInfo(diffEntity, project.getId(), categoryList, projectCategoryMap);
if (StringUtils.isNotBlank(project.getTopicId())){
if (StringUtils.isNotBlank(project.getTopicId())) {
//获取图片及话题内容
ResiTopicAndImgResultDTO topicInfo = topicService.getTopicAndImgs(project.getTopicId(),"image");
if (topicInfo != null){
ResiTopicAndImgResultDTO topicInfo = topicService.getTopicAndImgs(project.getTopicId(), "image");
if (topicInfo != null) {
diffEntity.setEventImgUrl(topicInfo.getTopicImgList().get(NumConstant.ZERO).getAttachmentUrl());
diffEntity.setEventContent(topicInfo.getTopicContent());
topicInfo.getTopicImgList().forEach(img -> {
ScreenDifficultyImgDataEntity imgData = new ScreenDifficultyImgDataEntity();
imgData.setEventId(project.getId());
imgData.setEventImgUrl(img.getAttachmentUrl());
imgData.setSort(img.getSort());
imgDataEntities.add(imgData);
});
log.info("projectId:{} imgs:{}", project.getId(), imgDataEntities.stream().filter(o -> o.getEventId().equals(project.getId())).count());
}
}
diffList.add(diffEntity);
log.info("========:"+JSON.toJSONString(diffList));
}
List<ScreenDifficultyDataEntity> collect = diffList.stream().filter(o -> o.getEventCostTime() < 5 * 24 * 60).collect(Collectors.toList());
log.info("========:" + JSON.toJSONString(collect));
log.info("========:" + JSON.toJSONString(diffList));
log.info("========:" + JSON.toJSONString(imgDataEntities));
//screenDifficultyDataService.dataClean(param.getCustomerId(),diffList,imgDataEntities);
log.info("【大屏数据抽取-难点赌点执行完毕】 客户Id{} 难点赌点数据{}", param.getCustomerId(), JSON.toJSONString(diffList));
//3.获取项目的最后操作记录
return false;
return true;
}
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)){
if (CollectionUtils.isEmpty(categorySet)) {
return;
}
projectCategoryMap.forEach((k,v) ->{
projectCategoryMap.forEach((k, v) -> {
List<IssueProjectCategoryDictEntity> childCategory = new ArrayList<>();
v.forEach(categoryCode-> getParentNode(childCategory,categoryList,categoryCode));
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);
@ -328,23 +372,24 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
ScreenDifficultyDataEntity diff = new ScreenDifficultyDataEntity();
diff.setCustomerId(project.getCustomerId());
//大屏的是逗号隔开的
String allPIds = project.getPids().replaceAll(StrConstant.COLON,StrConstant.COMMA);
String allPIds = project.getPids().replaceAll(StrConstant.COLON, StrConstant.COMMA);
DimAgencyEntity agencyInfoDTO = agencyMap.get(project.getAgencyId());
if (StringUtils.isBlank(project.getGridId())){
diff.setEventTitle(projectDTO.getTitle());
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.setAllParentIds(allPIds.replace(StrConstant.COMMA + project.getAgencyId(), StrConstant.EPMETY_STR));
diff.setOrgName(agencyInfoDTO.getAgencyName());
if (StringUtils.isNotBlank(agencyInfoDTO.getAllParentName())){
if (StringUtils.isNotBlank(agencyInfoDTO.getAllParentName())) {
diff.setEventSource(agencyInfoDTO.getAllParentName().concat(StrConstant.HYPHEN.concat(diff.getOrgName())));
}else{
} else {
diff.setEventSource(agencyInfoDTO.getAgencyName());
}
//如果是组织的则 设置背景为内容
diff.setEventContent(projectDTO.getBackGround());
}else{
} else {
diff.setOrgType("grid");
diff.setOrgId(project.getGridId());
diff.setParentId(project.getAgencyId());
@ -355,9 +400,9 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
String agencyAndGridName = agencyInfoDTO.getAgencyName().concat(StrConstant.HYPHEN.concat(diff.getOrgName()));
//todo 市北区的 allParentname 为什么为空
//if (!project.getPid().equals(NumConstant.ZERO_STR)){
if (StringUtils.isNotBlank(agencyInfoDTO.getAllParentName())){
if (StringUtils.isNotBlank(agencyInfoDTO.getAllParentName())) {
diff.setEventSource(agencyInfoDTO.getAllParentName().concat(StrConstant.HYPHEN).concat(agencyAndGridName));
}else{
} else {
diff.setEventSource(agencyAndGridName);
}
}
@ -365,14 +410,17 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
diff.setEventId(project.getId());
String projectStatus = project.getProjectStatus();
diff.setEventStatusCode(projectStatus);
if (ProjectConstant.PENDING.equals(projectStatus)){
if ("82ac5292612538eaf5c598005b7910ba".equals(project.getId())) {
System.out.println(JSON.toJSONString(projectDTO));
}
if (ProjectConstant.PENDING.equals(projectStatus)) {
diff.setEventStatusDesc("处理中");
//项目耗时 当前时间-项目创建时间
diff.setEventCostTime((int) ((System.currentTimeMillis()-projectDTO.getCreatedTime().getTime())/1000/60));
}else{
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.setEventCostTime((int) ((projectDTO.getUpdatedTime().getTime() - projectDTO.getCreatedTime().getTime()) / 1000 / 60));
}
//暂时不放内容 用不到
diff.setLatestOperateDesc("");
@ -382,6 +430,7 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
/**
* 递归查询父节点
*
* @param childCategory
* @param categoryList
* @param categoryCode

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml

@ -602,7 +602,7 @@
</select>
<select id="getProjectPeriodForDiff" resultType="com.epmet.entity.evaluationindex.extract.FactOriginProjectOrgPeriodDailyEntity">
SELECT
t.ID, t.CUSTOMER_ID, t.PROJECT_ID, t.ORG_ID, t.ORG_TYPE, t.PID,t. PIDS, t.INFORMED_DATE, t.HANDLED_DATE, t.TOTAL_PERIOD, t.PERIOD_TILL_REPLY_FIRSTLY, t.OPERATION
t.ID, t.CUSTOMER_ID, t.PROJECT_ID, t.ORG_ID, t.ORG_TYPE, t.PID,t. PIDS, t.INFORMED_DATE, t.HANDLED_DATE, t.TOTAL_PERIOD, t.PERIOD_TILL_REPLY_FIRSTLY, t.OPERATION, t.IS_RESOLVED
FROM fact_origin_project_org_period_daily t
WHERE CUSTOMER_ID = #{customerId}
</select>

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml

@ -129,7 +129,8 @@
CUSTOMER_ID,
PID,
AGENCY_NAME,
LEVEL
LEVEL,
ALL_PARENT_NAME
FROM
dim_agency
WHERE
@ -332,4 +333,4 @@
AND LEVEL = #{level}
</select>
</mapper>
</mapper>

Loading…
Cancel
Save