From 2f5efbca71aa8443282f8721960f69500725a119 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 14 Apr 2021 13:30:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=BE=E7=82=B9=E5=A0=B5=E7=82=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=9A=82=E5=AD=98-=E5=9F=BA=E6=9C=AC=E6=B2=A1?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BA=86=EF=BC=9B=E8=BF=98=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...srootsGovernDataAbsorptionServiceImpl.java | 195 +++++++++++------- .../extract/FactOriginProjectMainDailyDao.xml | 2 +- .../resources/mapper/stats/DimAgencyDao.xml | 5 +- 3 files changed, 126 insertions(+), 76 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java index 4461d75dc4..a5d539946a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java +++ b/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 gridList = customerGridService.queryGridInfoList(param.getCustomerId()); // list 转 map,以gridId为key,a = gridList,作为value,(o,n)->o 是遇到相同的gridId舍弃,(o,n)->n 是覆盖原来的gridId - Map gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO :: getGridId,a -> a,(o, n) -> o)); + Map gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO::getGridId, a -> a, (o, n) -> o)); //3.查询出客户下用户的累计积分(累计值,没有时间概念,否则需要查询积分明细计算出评价周期末的得分) - Map pointMap = userPointService.getUserPointMap(param.getCustomerId()); + Map 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 scoreMap = cpcIndexCalculateService.getCpcScore(param.getCustomerId(),dateId); + Map 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 difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(),projectService.getOvertimeProjectByParameter(param.getCustomerId())); - if(CollectionUtils.isEmpty(difficulties)) { + List difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(), projectService.getOvertimeProjectByParameter(param.getCustomerId())); + if (CollectionUtils.isEmpty(difficulties)) { return; } //2.查询出客户下网格的相关信息 List gridList = customerGridService.queryGridInfoList(param.getCustomerId()); - Map gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO :: getGridId,a -> a,(o, n) -> o)); + Map gridMap = gridList.stream().collect(Collectors.toMap(GridInfoDTO::getGridId, a -> a, (o, n) -> o)); //剔除垃圾数据(本次需要更新的数据集) //for(Iterator 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 projectIds = difficulties.stream().map(ScreenDifficultyDataEntity :: getEventId).distinct().collect(Collectors.toList()); + List projectIds = difficulties.stream().map(ScreenDifficultyDataEntity::getEventId).distinct().collect(Collectors.toList()); //最近一次操作 - Map latestOperationMap = projectProcessService.getLatestOperation(projectIds,param.getCustomerId()); + Map latestOperationMap = projectProcessService.getLatestOperation(projectIds, param.getCustomerId()); //图片 - List projectSourceMap = difficulties.stream().map(diff->{ + List 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> imgMap = topicService.getTopicImgs(projectSourceMap); + Map> imgMap = topicService.getTopicImgs(projectSourceMap); - Map contentMap = topicService.getTopicContent(projectSourceMap); + Map contentMap = topicService.getTopicContent(projectSourceMap); - difficulties.forEach( diff -> { + difficulties.forEach(diff -> { - List figureList = CollectionUtils.isEmpty(imgMap) ? null : imgMap.get(diff.getEventId()); - diff.setEventImgUrl(CollectionUtils.isEmpty(figureList) ? "" : figureList.get(NumConstant.ZERO).getEventImgUrl()); + List 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 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 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 bizProjectInfoMap = bizProjectInfoList.stream().collect(Collectors.toMap(ProjectDTO::getId, o -> o, (o1, o2) -> o1)); @@ -248,72 +249,115 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr //2.获取项目的所有节点耗时数据 List projectPeriodList = factOriginProjectMainDailyService.getProjectPeriod(param); - Map orgCountMap = new HashMap<>(); - Map handleCountMap = new HashMap<>(); - projectPeriodList.forEach(period->{ - Integer orgCount = orgCountMap.get(period.getProjectId()); - if (orgCount == null){ - orgCount = 0; - }else{ - ++orgCount; + //处理部门数去重(只要流转到就算) + Map> orgCountMap = new HashMap<>(); + //被处理次数 + Map handleCountMap = new HashMap<>(); + //已经结案的项目的结案时间 + Set valideProjectIdSet = new HashSet<>(); + Map 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 informDate = new HashMap<>(); + projectPeriodList.forEach(period -> { + Set 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 diffList = new ArrayList<>(); + List 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 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 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 categoryList, Map> projectCategoryMap) { Set categorySet = projectCategoryMap.get(projectId); - if (CollectionUtils.isEmpty(categorySet)){ + if (CollectionUtils.isEmpty(categorySet)) { return; } - projectCategoryMap.forEach((k,v) ->{ + projectCategoryMap.forEach((k, v) -> { List 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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml index 9935094e55..18635a23df 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml @@ -602,7 +602,7 @@ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml index f0df043bf5..6881886600 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml +++ b/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} - \ No newline at end of file +