@ -1,9 +1,11 @@
package com.epmet.service.evaluationindex.extract.toscreen.impl ;
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.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.entity.evaluationindex.screen.ScreenDifficultyDataEntity ;
@ -21,16 +23,13 @@ import com.epmet.service.project.ProjectService;
import com.epmet.service.topic.TopicService ;
import com.epmet.service.user.UserService ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
import org.springframework.util.StringUtils ;
import java.math.BigDecimal ;
import java.util.HashMap ;
import java.util.LinkedList ;
import java.util.List ;
import java.util.Map ;
import java.util.* ;
import java.util.stream.Collectors ;
@ -79,8 +78,7 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
//2.查询出客户下网格的相关信息
List < GridInfoDTO > gridList = customerGridService . queryGridInfoList ( param . getCustomerId ( ) ) ;
Map < String , GridInfoDTO > gridMap = new HashMap < > ( ) ;
gridList . forEach ( grid - > { gridMap . put ( grid . getGridId ( ) , grid ) ; } ) ;
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 ( ) ) ;
@ -91,16 +89,22 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
dateId = DateUtils . getBeforeNMonth ( NumConstant . ONE ) ;
} else {
String dateType = DateUtils . identifyTimeDimension ( dateId ) ;
if ( StringUtils . isEmpty ( dateType ) | | ! org . apache . commons . lang3 . StringUtils . equalsAny ( dateType , "date" , "month" ) ) {
if ( StringUtils . isEmpty ( dateType ) | | ! StringUtils . equalsAny ( dateType , "date" , "month" ) ) {
dateId = DateUtils . getBeforeNMonth ( NumConstant . ONE ) ;
} else if ( org . apache . commons . lang3 . StringUtils . equals ( dateType , "date" ) ) {
dateId = dateId . substring ( NumConstant . ZERO , dateId . length ( ) - NumConstant . TWO ) ;
} else if ( StringUtils . equals ( dateType , "date" ) ) {
dateId = dateId . substring ( NumConstant . ZERO , dateId . length ( ) - NumConstant . TWO ) ;
}
}
final String finalDateId = dateId ;
Map < String , BigDecimal > scoreMap = cpcIndexCalculateService . getCpcScore ( param . getCustomerId ( ) , dateId ) ;
//剔除垃圾数据
for ( Iterator < ScreenPartyUserRankDataEntity > iter = registeredUsers . iterator ( ) ;
iter . hasNext ( ) ; ) {
if ( null = = gridMap . get ( iter . next ( ) . getGridId ( ) ) ) iter . remove ( ) ;
}
//5.整合数据
if ( ! CollectionUtils . isEmpty ( registeredUsers ) ) {
registeredUsers . forEach ( user - > {
@ -125,7 +129,19 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
//6.存入数据库
//不按照时间删除,每次插入之前将该客户下的所有历史数据清空
screenPartyUserRankDataService . dataClean ( registeredUsers , param . getCustomerId ( ) ) ;
//过滤 统计维度中没有的数据
Set < String > gridIdSet = new HashSet < > ( ) ;
List < ScreenPartyUserRankDataEntity > newInsertList = registeredUsers . stream ( )
. filter ( o - > {
if ( StringUtils . isBlank ( o . getGridName ( ) ) ) {
gridIdSet . add ( o . getGridId ( ) ) ;
return false ;
} else {
return true ;
}
} ) . collect ( Collectors . toList ( ) ) ;
log . warn ( "userScoreDataHub grids:{} not in DimGrid" , JSON . toJSONString ( gridIdSet ) ) ;
screenPartyUserRankDataService . dataClean ( newInsertList , param . getCustomerId ( ) ) ;
}
/ * *
@ -144,13 +160,26 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
//查询数据
List < ScreenDifficultyDataEntity > difficulties = factOriginProjectMainDailyService . getDifficultyBaseInfo ( param . getCustomerId ( ) , projectService . getOvertimeProjectByParameter ( param . getCustomerId ( ) , existed ) ) ;
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 ) ) ;
List < String > missing = new LinkedList < > ( ) ;
for ( Iterator < ScreenDifficultyDataEntity > iter = difficulties . iterator ( ) ; iter . hasNext ( ) ; ) {
ScreenDifficultyDataEntity pointer = iter . next ( ) ;
if ( null = = gridMap . get ( pointer . getOrgId ( ) ) ) {
missing . add ( pointer . getEventId ( ) ) ;
iter . remove ( ) ;
}
}
List < String > projectIds = difficulties . stream ( ) . map ( ScreenDifficultyDataEntity : : getEventId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
//最近一次操作
Map < String , String > latestOperationMap = projectProcessService . getLatestOperation ( projectIds , param . getCustomerId ( ) ) ;
//标题
Map < String , String > titleMap = projectProcessService . getProjectTitle ( projectIds , param . getCustomerId ( ) ) ;
Map < String , ProjectLatestOperationResultDTO > latestOperationMap = projectProcessService . getLatestOperation ( projectIds , param . getCustomerId ( ) ) ;
boolean isOperationNull = CollectionUtils . isEmpty ( latestOperationMap ) ? true : false ;
boolean isTitleNull = CollectionUtils . isEmpty ( titleMap ) ? true : false ;
//图片
List < ProjectSourceMapFormDTO > projectSourceMap = factOriginProjectMainDailyService . getNewProject ( param . getCustomerId ( ) , projectIds ) ;
@ -168,16 +197,20 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
diff . setEventContent ( contentMap . get ( diff . getEventId ( ) ) ) ;
}
if ( ! isOperationNull ) {
diff . setLatestOperateDesc ( latestOperationMap . get ( diff . getEventId ( ) ) ) ;
}
if ( ! isTitleNull ) {
diff . setEventTitle ( titleMap . get ( diff . getEventId ( ) ) ) ;
ProjectLatestOperationResultDTO oper = latestOperationMap . get ( diff . getEventId ( ) ) ;
if ( null ! = oper ) {
diff . setLatestOperateDesc ( oper . getOperationName ( ) ) ;
diff . setEventTitle ( oper . getTitle ( ) ) ;
diff . setEventCostTime ( oper . getCostTime ( ) ) ;
}
}
diff . setDataEndTime ( DateUtils . getBeforeNDay ( NumConstant . ONE ) ) ;
} ) ;
List < ScreenDifficultyImgDataEntity > imgList = new LinkedList < > ( ) ;
imgMap . values ( ) . forEach ( list - > { imgList . addAll ( list ) ; } ) ;
screenDifficultyDataService . dataClean ( param . getCustomerId ( ) , difficulties , imgList ) ;
screenDifficultyDataService . dataClean ( param . getCustomerId ( ) , difficulties , imgList , missing ) ;
}
}