@ -17,11 +17,7 @@ import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.stats.form.GmUploadEventFormDTO ;
import com.epmet.dto.stats.user.* ;
import com.epmet.dto.stats.user.result.UserStatisticalData ;
import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO ;
import com.epmet.dto.user.result.StaffRoleInfoDTO ;
import com.epmet.dto.user.result.CustomerStaffDTO ;
import com.epmet.dto.user.result.StaffPatrolRecordResult ;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO ;
import com.epmet.dto.user.result.* ;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity ;
import com.epmet.service.user.UserService ;
import com.epmet.util.DimIdGenerator ;
@ -120,14 +116,16 @@ public class UserServiceImpl implements UserService {
if ( null ! = agencyMap & & agencyMap . size ( ) > NumConstant . ZERO ) {
agencyMap . forEach ( ( agencyId , v ) - > {
if ( null ! = v & & v . size ( ) > NumConstant . ZERO ) {
queryUserData ( ModuleConstant . DIM_BELONGING_GRID ,
/ * queryUserData ( ModuleConstant . DIM_BELONGING_GRID ,
agencyId ,
// v.get(NumConstant.ZERO).getPid(),
v . get ( NumConstant . ZERO ) . getCustomerId ( ) ,
new HashSet < > ( v . get ( NumConstant . ZERO ) . getGridIds ( ) ) ,
targetDate ,
dataPacket ,
timeDimension ) ;
timeDimension ) ; * /
traverseGridUserDispose ( agencyId , v . get ( NumConstant . ZERO ) . getCustomerId ( ) , new HashSet < > ( v . get ( NumConstant . ZERO ) . getGridIds ( ) )
, targetDate , dataPacket , timeDimension ) ;
}
} ) ;
}
@ -709,6 +707,221 @@ public class UserServiceImpl implements UserService {
}
/ * *
* @Description
* @Param agencyId 组织ID
* @Param customerId 客户ID
* @Param gridIds 网格IDS
* @Param targetDate dateId 日期 eg : 2021 - 07 - 27
* @Param dataPacket 数据包
* @Param timeDimension 日期维度
* @author zxc
* @date 2021 / 7 / 27 9 : 53 上午
* /
void traverseGridUserDispose ( String agencyId , String customerId , Set < String > gridIds , Date targetDate , UserStatisticalData dataPacket , DimIdGenerator . DimIdBean timeDimension ) {
if ( CollectionUtils . isEmpty ( gridIds ) ) {
return ;
}
dataPacket . setCustomerId ( customerId ) ;
//计算百分比使用,保留小数点后两位
NumberFormat numberFormat = NumberFormat . getInstance ( ) ;
numberFormat . setMaximumFractionDigits ( NumConstant . SIX ) ;
Calendar calendar = Calendar . getInstance ( ) ;
//求出T-1
calendar . setTime ( new Date ( ) ) ;
calendar . add ( Calendar . DATE , NumConstant . ONE_NEG ) ;
//指定日期 OR T-1
calendar . setTime ( calendar . getTime ( ) ) ;
//求出这个月的第一天
calendar . set ( Calendar . DAY_OF_MONTH , NumConstant . ONE ) ;
calendar . set ( Calendar . HOUR_OF_DAY , NumConstant . ZERO ) ;
calendar . set ( Calendar . MINUTE , NumConstant . ZERO ) ;
calendar . set ( Calendar . SECOND , NumConstant . ZERO ) ;
//1.计算机关下注册用户一个时间单位内的累计与增长
List < TotalAndIncrResultDTO > regData = userDao . selectResiTotalAndIncrByGridIds ( ModuleConstant . REG_OR_PARTI_FLAG_REG , gridIds , targetDate , calendar . getTime ( ) ) ;
//2.查询注册用户的Id列表
// 增长
List < IncrAndTotalUserIdsResultDTO > incrRegUsers = userDao . selectIncrUserIdsByGrids ( ModuleConstant . REG_OR_PARTI_FLAG_REG , gridIds , targetDate , "incr" , calendar . getTime ( ) ) ;
List < String > incrUserIds = new ArrayList < > ( ) ;
if ( ! CollectionUtils . isEmpty ( incrRegUsers ) ) {
incrRegUsers . forEach ( i - > {
if ( ! CollectionUtils . isEmpty ( i . getUserIds ( ) ) ) {
incrUserIds . addAll ( i . getUserIds ( ) ) ;
}
} ) ;
}
// 全部
List < IncrAndTotalUserIdsResultDTO > totalRegUsers = userDao . selectIncrUserIdsByGrids ( ModuleConstant . REG_OR_PARTI_FLAG_REG , gridIds , targetDate , "total" , calendar . getTime ( ) ) ;
List < String > totalUserIds = new ArrayList < > ( ) ;
if ( ! CollectionUtils . isEmpty ( totalRegUsers ) ) {
totalRegUsers . forEach ( t - > {
if ( ! CollectionUtils . isEmpty ( t . getUserIds ( ) ) ) {
totalUserIds . addAll ( t . getUserIds ( ) ) ;
}
} ) ;
}
//3.查询机关下一个时间单位内热心居民的累计与增量(注册用户)
List < WarmTotalAndIncrResultDTO > warmRegData = userDao . selectWarmTotalAndIncrByGrids ( totalUserIds , incrUserIds , gridIds , targetDate , calendar . getTime ( ) ) ;
//4.查询机关下一个时间单位内党员的累计与增量(注册用户)
List < PartyTotalAndIncrResultDTO > partyRegData = userDao . selectPartyTotalAndIncrNew ( targetDate , ModuleConstant . REG_OR_PARTI_FLAG_REG , calendar . getTime ( ) ) ;
//参与用户
//1.计算机关下参与用户一个时间单位内的累计与增长
List < TotalAndIncrResultDTO > partiData = userDao . selectResiTotalAndIncrByGridIds ( ModuleConstant . REG_OR_PARTI_FLAG_PARTI , gridIds , targetDate , calendar . getTime ( ) ) ;
//2.查询参与用户的Id列表[增长]
List < IncrAndTotalUserIdsResultDTO > incrPartiUsers = userDao . selectIncrUserIdsByGrids ( ModuleConstant . REG_OR_PARTI_FLAG_PARTI , gridIds , targetDate , "incr" , calendar . getTime ( ) ) ;
List < String > incrPartiUserIds = new ArrayList < > ( ) ;
if ( ! CollectionUtils . isEmpty ( incrPartiUsers ) ) {
incrPartiUsers . forEach ( i - > {
if ( ! CollectionUtils . isEmpty ( i . getUserIds ( ) ) ) {
incrPartiUserIds . addAll ( i . getUserIds ( ) ) ;
}
} ) ;
}
// 查询参与用户的Id列表[全部]
List < IncrAndTotalUserIdsResultDTO > totalPartiUsers = userDao . selectIncrUserIdsByGrids ( ModuleConstant . REG_OR_PARTI_FLAG_PARTI , gridIds , targetDate , "total" , calendar . getTime ( ) ) ;
List < String > totalPartiUserIds = new ArrayList < > ( ) ;
if ( ! CollectionUtils . isEmpty ( totalPartiUsers ) ) {
totalPartiUsers . forEach ( t - > {
if ( ! CollectionUtils . isEmpty ( t . getUserIds ( ) ) ) {
totalPartiUserIds . addAll ( t . getUserIds ( ) ) ;
}
} ) ;
}
//3.查询机关下一个时间单位内热心居民的累计与增量(参与用户)
List < WarmTotalAndIncrResultDTO > warmPartiData = userDao . selectWarmTotalAndIncrByGrids ( totalPartiUserIds , incrPartiUserIds , gridIds , targetDate , calendar . getTime ( ) ) ;
//4.查询机关下一个时间单位内党员的累计与增量(参与用户)
List < PartyTotalAndIncrResultDTO > partyPartiData = userDao . selectPartyTotalAndIncrNew ( targetDate , ModuleConstant . REG_OR_PARTI_FLAG_PARTI , calendar . getTime ( ) ) ;
/** ==================== *开始组装数据* ==================== **/
gridIds . forEach ( gridId - > {
//注册用户网格级别
FactRegUserGridDailyDTO regGridD = new FactRegUserGridDailyDTO ( ) ;
regGridD . setCustomerId ( customerId ) ;
regGridD . setGridId ( gridId ) ;
regGridD . setAgencyId ( agencyId ) ;
regGridD . setDateId ( timeDimension . getDateId ( ) ) ;
regGridD . setWeekId ( timeDimension . getWeekId ( ) ) ;
regGridD . setYearId ( timeDimension . getYearId ( ) ) ;
regGridD . setCreatedBy ( ModuleConstant . CREATED_BY_STATISTICAL_ROBOT ) ;
regGridD . setResiProportion ( new BigDecimal ( NumConstant . ONE ) ) ;
//参与用户网格级别
FactParticipationUserGridDailyDTO partiGridD = new FactParticipationUserGridDailyDTO ( ) ;
partiGridD . setCustomerId ( customerId ) ;
partiGridD . setGridId ( gridId ) ;
partiGridD . setAgencyId ( agencyId ) ;
partiGridD . setDateId ( timeDimension . getDateId ( ) ) ;
partiGridD . setWeekId ( timeDimension . getWeekId ( ) ) ;
partiGridD . setYearId ( timeDimension . getYearId ( ) ) ;
partiGridD . setCreatedBy ( ModuleConstant . CREATED_BY_STATISTICAL_ROBOT ) ;
partiGridD . setResiProportion ( new BigDecimal ( NumConstant . ONE ) ) ;
FactRegUserGridMonthlyDTO regGridM = new FactRegUserGridMonthlyDTO ( ) ;
regGridM . setCustomerId ( customerId ) ;
regGridM . setGridId ( gridId ) ;
regGridM . setAgencyId ( agencyId ) ;
regGridM . setMonthId ( timeDimension . getMonthId ( ) ) ;
regGridM . setQuarterId ( timeDimension . getQuarterId ( ) ) ;
regGridM . setYearId ( timeDimension . getYearId ( ) ) ;
regGridM . setPartymemberProportion ( regGridD . getPartymemberProportion ( ) ) ;
regGridM . setWarmHeartedProportion ( regGridD . getWarmHeartedProportion ( ) ) ;
regGridM . setCreatedBy ( ModuleConstant . CREATED_BY_STATISTICAL_ROBOT ) ;
regGridM . setResiProportion ( new BigDecimal ( NumConstant . ONE ) ) ;
FactParticipationUserGridMonthlyDTO partiGridM = new FactParticipationUserGridMonthlyDTO ( ) ;
partiGridM . setCustomerId ( customerId ) ;
partiGridM . setGridId ( gridId ) ;
partiGridM . setAgencyId ( agencyId ) ;
partiGridM . setMonthId ( timeDimension . getMonthId ( ) ) ;
partiGridM . setQuarterId ( timeDimension . getQuarterId ( ) ) ;
partiGridM . setYearId ( timeDimension . getYearId ( ) ) ;
partiGridM . setCreatedBy ( ModuleConstant . CREATED_BY_STATISTICAL_ROBOT ) ;
partiGridM . setResiProportion ( new BigDecimal ( NumConstant . ONE ) ) ;
if ( ! CollectionUtils . isEmpty ( regData ) ) {
for ( TotalAndIncrResultDTO r : regData ) {
if ( gridId . equals ( r . getGridId ( ) ) ) {
regGridD . setResiTotal ( r . getTotal ( ) ) ;
regGridD . setRegTotal ( r . getTotal ( ) ) ;
regGridD . setRegIncr ( r . getIncr ( ) ) ;
regGridM . setRegTotal ( r . getTotal ( ) ) ;
regGridM . setResiTotal ( r . getTotal ( ) ) ;
regGridM . setRegIncr ( r . getIncr ( ) ) ;
break ;
}
}
}
if ( ! CollectionUtils . isEmpty ( warmRegData ) ) {
for ( WarmTotalAndIncrResultDTO w : warmRegData ) {
if ( gridId . equals ( w . getGridId ( ) ) ) {
regGridD . setWarmHeartedTotal ( w . getTotal ( ) ) ;
regGridD . setWarmIncr ( w . getIncr ( ) ) ;
regGridM . setWarmHeartedTotal ( w . getTotal ( ) ) ;
regGridM . setWarmIncr ( w . getIncr ( ) ) ;
break ;
}
}
}
if ( ! CollectionUtils . isEmpty ( partiData ) ) {
for ( TotalAndIncrResultDTO p : partiData ) {
if ( gridId . equals ( p . getGridId ( ) ) ) {
partiGridD . setResiTotal ( p . getTotal ( ) ) ;
partiGridD . setRegTotal ( p . getTotal ( ) ) ;
partiGridD . setRegIncr ( p . getIncr ( ) ) ;
partiGridM . setRegTotal ( p . getTotal ( ) ) ;
partiGridM . setResiTotal ( p . getTotal ( ) ) ;
partiGridM . setRegIncr ( p . getIncr ( ) ) ;
break ;
}
}
}
if ( ! CollectionUtils . isEmpty ( partyRegData ) ) {
for ( PartyTotalAndIncrResultDTO p : partyRegData ) {
if ( gridId . equals ( p . getGridId ( ) ) ) {
regGridD . setPartymemberTotal ( p . getTotal ( ) ) ;
regGridD . setPartymemberIncr ( p . getIncr ( ) ) ;
regGridM . setPartymemberTotal ( p . getTotal ( ) ) ;
regGridM . setPartymemberIncr ( p . getIncr ( ) ) ;
regGridM . setPartymemberTotal ( p . getTotal ( ) ) ;
regGridM . setPartymemberIncr ( p . getIncr ( ) ) ;
break ;
}
}
}
if ( ! CollectionUtils . isEmpty ( warmPartiData ) ) {
for ( WarmTotalAndIncrResultDTO w : warmPartiData ) {
if ( gridId . equals ( w . getGridId ( ) ) ) {
partiGridD . setWarmHeartedTotal ( w . getTotal ( ) ) ;
partiGridD . setWarmIncr ( w . getIncr ( ) ) ;
partiGridM . setWarmHeartedTotal ( w . getTotal ( ) ) ;
partiGridM . setWarmIncr ( w . getIncr ( ) ) ;
break ;
}
}
}
if ( ! CollectionUtils . isEmpty ( partyPartiData ) ) {
for ( PartyTotalAndIncrResultDTO p : partyPartiData ) {
if ( gridId . equals ( p . getGridId ( ) ) ) {
partiGridD . setPartymemberTotal ( p . getTotal ( ) ) ;
partiGridD . setPartymemberIncr ( p . getIncr ( ) ) ;
partiGridM . setPartymemberTotal ( p . getTotal ( ) ) ;
partiGridM . setPartymemberIncr ( p . getIncr ( ) ) ;
break ;
}
}
}
regGridD . setPartymemberProportion ( regGridD . getRegTotal ( ) = = NumConstant . ZERO ? BigDecimal . ZERO : new BigDecimal ( numberFormat . format ( ( float ) regGridD . getPartymemberTotal ( ) / ( float ) regGridD . getRegTotal ( ) ) ) ) ;
regGridD . setWarmHeartedProportion ( regGridD . getRegTotal ( ) = = NumConstant . ZERO ? BigDecimal . ZERO : new BigDecimal ( numberFormat . format ( ( float ) regGridD . getWarmHeartedTotal ( ) / ( float ) regGridD . getRegTotal ( ) ) ) ) ;
partiGridD . setPartymemberProportion ( partiGridD . getPartymemberTotal ( ) = = NumConstant . ZERO ? BigDecimal . ZERO : new BigDecimal ( numberFormat . format ( ( float ) partiGridD . getPartymemberTotal ( ) / ( float ) partiGridD . getRegTotal ( ) ) ) ) ;
partiGridD . setWarmHeartedProportion ( partiGridD . getPartymemberTotal ( ) = = NumConstant . ZERO ? BigDecimal . ZERO : new BigDecimal ( numberFormat . format ( ( float ) partiGridD . getWarmHeartedTotal ( ) / ( float ) partiGridD . getRegTotal ( ) ) ) ) ;
regGridM . setPartymemberProportion ( regGridD . getPartymemberProportion ( ) ) ;
regGridM . setWarmHeartedProportion ( regGridD . getWarmHeartedProportion ( ) ) ;
partiGridM . setPartymemberProportion ( partiGridD . getPartymemberProportion ( ) ) ;
partiGridM . setWarmHeartedProportion ( partiGridD . getWarmHeartedProportion ( ) ) ;
dataPacket . getRegGridDailyList ( ) . add ( regGridD ) ;
dataPacket . getPartiGridDailyList ( ) . add ( partiGridD ) ;
dataPacket . getRegGridMonthlyList ( ) . add ( regGridM ) ;
dataPacket . getPartiGridMonthlyList ( ) . add ( partiGridM ) ;
} ) ;
}
/ * *
* @return java . util . List < java . lang . String >