@ -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,19 @@ 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 ) ;
//剔除垃圾数据
registeredUsers . removeIf ( user - > null = = gridMap . get ( user . getGridId ( ) ) ) ;
//5.整合数据
if ( ! CollectionUtils . isEmpty ( registeredUsers ) ) {
registeredUsers . forEach ( user - > {
@ -120,12 +121,8 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
user . setDataEndTime ( finalDateId ) ;
} ) ;
}
//6.存入数据库
//不按照时间删除,每次插入之前将该客户下的所有历史数据清空
screenPartyUserRankDataService . dataClean ( registeredUsers , param . getCustomerId ( ) ) ;
screenPartyUserRankDataService . dataClean ( registeredUsers , param . getCustomerId ( ) ) ;
}
/ * *
@ -137,42 +134,51 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
* * /
@Override
public void difficultyDataHub ( ScreenCentralZoneDataFormDTO param ) {
//查询难点赌点中有无已结案的项目,若有则保留
List < String > existed = screenDifficultyDataService . selectExistedInfo ( param . getCustomerId ( ) ) ;
//查询数据
List < ScreenDifficultyDataEntity > difficulties = factOriginProjectMainDailyService . getDifficultyBaseInfo ( param . getCustomerId ( ) , projectService . getOvertimeProjectByParameter ( param . getCustomerId ( ) , existed ) ) ;
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 ) ) ;
//剔除垃圾数据(本次需要更新的数据集)
//for(Iterator<ScreenDifficultyDataEntity> iter = difficulties.iterator(); iter.hasNext();){
// ScreenDifficultyDataEntity pointer = iter.next();
// if(null == gridMap.get(pointer.getOrgId())){
// iter.remove();
// }
//}
difficulties . removeIf ( diff - > null = = gridMap . get ( diff . getOrgId ( ) ) ) ;
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 ( ) ) ;
boolean isOperationNull = CollectionUtils . isEmpty ( latestOperationMap ) ? true : false ;
boolean isTitleNull = CollectionUtils . isEmpty ( titleMap ) ? true : false ;
Map < String , ProjectLatestOperationResultDTO > latestOperationMap = projectProcessService . getLatestOperation ( projectIds , param . getCustomerId ( ) ) ;
//图片
List < ProjectSourceMapFormDTO > projectSourceMap = factOriginProjectMainDailyService . getNewProject ( param . getCustomerId ( ) , projectIds ) ;
Map < String , List < ScreenDifficultyImgDataEntity > > imgMap =
topicService . getTopicImgs ( projectSourceMap ) ;
boolean isImgNull = CollectionUtils . isEmpty ( imgMap ) ? true : false ;
Map < String , String > contentMap = topicService . getTopicContent ( projectSourceMap ) ;
boolean isContentNull = CollectionUtils . isEmpty ( contentMap ) ? true : false ;
difficulties . forEach ( diff - > {
if ( ! isImgNull ) {
if ( ! CollectionUtils . isEmpty ( imgMap ) ) {
List < ScreenDifficultyImgDataEntity > figureList = imgMap . get ( diff . getEventId ( ) ) ;
diff . setEventImgUrl ( CollectionUtils . isEmpty ( figureList ) ? "" : figureList . get ( NumConstant . ZERO ) . getEventImgUrl ( ) ) ;
}
if ( ! isContentNull ) {
if ( ! CollectionUtils . isEmpty ( contentMap ) ) {
diff . setEventContent ( contentMap . get ( diff . getEventId ( ) ) ) ;
}
if ( ! isOperationNull ) {
diff . setLatestOperateDesc ( latestOperationMap . get ( diff . getEventId ( ) ) ) ;
}
if ( ! isTitleNull ) {
diff . setEventTitle ( titleMap . get ( diff . getEventId ( ) ) ) ;
if ( ! CollectionUtils . isEmpty ( latestOperationMap ) ) {
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 < > ( ) ;