|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.epmet.service.user.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
@ -8,6 +9,7 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.UserAnalysisConstant; |
|
|
|
import com.epmet.dao.user.UserAnalysisDao; |
|
|
|
import com.epmet.dto.DimAgencyDTO; |
|
|
|
import com.epmet.dto.DimGridDTO; |
|
|
|
import com.epmet.dto.form.LoginUserDetailsFormDTO; |
|
|
|
import com.epmet.dto.form.user.UserIncrTrendFormDTO; |
|
|
|
import com.epmet.dto.form.user.UserSubAgencyFormDTO; |
|
|
@ -108,8 +110,9 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { |
|
|
|
//获取用户所属机关id
|
|
|
|
String myAgencyId = this.getMyAgency(); |
|
|
|
//初始化横坐标(用户所机关的下级机关列表)
|
|
|
|
List<UserSubAgencyResultDTO> returnList = this.initUserSubAgencyResultDTO(myAgencyId); |
|
|
|
if(CollectionUtils.isEmpty(returnList)){ |
|
|
|
List<UserSubAgencyResultDTO> dimList = this.initUserSubAgencyResultDTO(myAgencyId); |
|
|
|
if(CollectionUtils.isEmpty(dimList)){ |
|
|
|
logger.info(String.format("当前机关(agencyId=%s)下没有下级机关",myAgencyId)); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
//根据入参,查询注册用户或者参与用户的(机关、按日的查询结果)
|
|
|
@ -124,33 +127,38 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { |
|
|
|
myAgencyId); |
|
|
|
} |
|
|
|
//根据维度表进行对比
|
|
|
|
for(UserSubAgencyResDTO userSubAgencyResDTO:userSubAgencyResDTOList){ |
|
|
|
for(UserSubAgencyResultDTO returnResultDTO:returnList){ |
|
|
|
if(returnResultDTO.getAgencyId().equals(userSubAgencyResDTO.getAgencyId())){ |
|
|
|
for(UserSubAgencyResultDTO dimInitResultDto:dimList){ |
|
|
|
boolean flag=false; |
|
|
|
for(UserSubAgencyResDTO userSubAgencyResDTO:userSubAgencyResDTOList){ |
|
|
|
if(dimInitResultDto.getAgencyId().equals(userSubAgencyResDTO.getAgencyId())){ |
|
|
|
flag=true; |
|
|
|
//居民、热心居民、党员总数,用于排序
|
|
|
|
returnResultDTO.setTotal(userSubAgencyResDTO.getPartymemberTotal() |
|
|
|
dimInitResultDto.setTotal(userSubAgencyResDTO.getPartymemberTotal() |
|
|
|
+userSubAgencyResDTO.getWarmHeartedTotal() |
|
|
|
+userSubAgencyResDTO.getResiTotal()); |
|
|
|
switch(returnResultDTO.getType()){ |
|
|
|
switch(dimInitResultDto.getType()){ |
|
|
|
case UserAnalysisConstant.REGISTERED_RESI: |
|
|
|
returnResultDTO.setValue(userSubAgencyResDTO.getResiTotal()); |
|
|
|
dimInitResultDto.setValue(userSubAgencyResDTO.getResiTotal()); |
|
|
|
break; |
|
|
|
case UserAnalysisConstant.WARMHEARTED: |
|
|
|
returnResultDTO.setValue(userSubAgencyResDTO.getWarmHeartedTotal()); |
|
|
|
dimInitResultDto.setValue(userSubAgencyResDTO.getWarmHeartedTotal()); |
|
|
|
break; |
|
|
|
case UserAnalysisConstant.PARTYMEMBER: |
|
|
|
returnResultDTO.setValue(userSubAgencyResDTO.getPartymemberTotal()); |
|
|
|
dimInitResultDto.setValue(userSubAgencyResDTO.getPartymemberTotal()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!flag){ |
|
|
|
logger.error(String.format("各机关注册用户数缺少记录:date_id=%s,agencyId=%s",formDTO.getDateId(),dimInitResultDto.getAgencyId())); |
|
|
|
} |
|
|
|
} |
|
|
|
//返回集合按照total降序排序
|
|
|
|
List<UserSubAgencyResultDTO> newList = returnList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal)) |
|
|
|
List<UserSubAgencyResultDTO> returnList = dimList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
return newList; |
|
|
|
return returnList; |
|
|
|
} |
|
|
|
|
|
|
|
private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String myAgencyId) { |
|
|
@ -161,25 +169,25 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { |
|
|
|
UserSubAgencyResultDTO resi=new UserSubAgencyResultDTO(); |
|
|
|
resi.setAgencyId(agencyDTO.getId()); |
|
|
|
resi.setName(agencyDTO.getAgencyName()); |
|
|
|
resi.setValue(0); |
|
|
|
resi.setValue(NumConstant.ZERO); |
|
|
|
resi.setType(UserAnalysisConstant.REGISTERED_RESI); |
|
|
|
resi.setTotal(0); |
|
|
|
resi.setTotal(NumConstant.ZERO); |
|
|
|
list.add(resi); |
|
|
|
//热心居民
|
|
|
|
UserSubAgencyResultDTO warm=new UserSubAgencyResultDTO(); |
|
|
|
warm.setAgencyId(agencyDTO.getId()); |
|
|
|
warm.setName(agencyDTO.getAgencyName()); |
|
|
|
warm.setValue(0); |
|
|
|
warm.setValue(NumConstant.ZERO); |
|
|
|
warm.setType(UserAnalysisConstant.WARMHEARTED); |
|
|
|
warm.setTotal(0); |
|
|
|
warm.setTotal(NumConstant.ZERO); |
|
|
|
list.add(warm); |
|
|
|
//党员
|
|
|
|
UserSubAgencyResultDTO party=new UserSubAgencyResultDTO(); |
|
|
|
party.setAgencyId(agencyDTO.getId()); |
|
|
|
party.setName(agencyDTO.getAgencyName()); |
|
|
|
party.setValue(0); |
|
|
|
party.setValue(NumConstant.ZERO); |
|
|
|
party.setType(UserAnalysisConstant.PARTYMEMBER); |
|
|
|
party.setTotal(0); |
|
|
|
party.setTotal(NumConstant.ZERO); |
|
|
|
list.add(party); |
|
|
|
} |
|
|
|
return list; |
|
|
@ -194,7 +202,88 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<UserSubGridResultDTO> subGrid(UserSubGridFormDTO formDTO) { |
|
|
|
return null; |
|
|
|
//获取用户所属机关id
|
|
|
|
String myAgencyId = this.getMyAgency(); |
|
|
|
//初始化横坐标(用户所机关的直属网格)
|
|
|
|
List<UserSubGridResultDTO> dimList = this.initUserSubGridResultDTO(myAgencyId); |
|
|
|
if(CollectionUtils.isEmpty(dimList)){ |
|
|
|
logger.info(String.format("当前机关(agencyId=%s)下没有网格",myAgencyId)); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
//根据入参,查询注册用户或者参与用户的(机关、按日的查询结果)
|
|
|
|
List<UserSubGridResDTO> userSubGridResDTOS=new ArrayList<>(); |
|
|
|
if (UserAnalysisConstant.PARTI_FLAG.equals(formDTO.getRegOrPartiFlag())) { |
|
|
|
//参与用户
|
|
|
|
userSubGridResDTOS=userAnalysisDao.selectParticipationSubGridRes(formDTO.getDateId(),myAgencyId); |
|
|
|
} else { |
|
|
|
//注册用户
|
|
|
|
userSubGridResDTOS=userAnalysisDao.selectRegSubGridRes(formDTO.getDateId(),myAgencyId); |
|
|
|
} |
|
|
|
//根据维度表进行对比
|
|
|
|
for(UserSubGridResultDTO dimInitResultDto:dimList){ |
|
|
|
boolean flag=false; |
|
|
|
for(UserSubGridResDTO userSubGridResDTO:userSubGridResDTOS){ |
|
|
|
if(dimInitResultDto.getGridId().equals(userSubGridResDTO.getGridId())){ |
|
|
|
flag=true; |
|
|
|
//居民、热心居民、党员总数,用于排序
|
|
|
|
dimInitResultDto.setTotal(userSubGridResDTO.getPartymemberTotal() |
|
|
|
+userSubGridResDTO.getWarmHeartedTotal() |
|
|
|
+userSubGridResDTO.getResiTotal()); |
|
|
|
switch(dimInitResultDto.getType()){ |
|
|
|
case UserAnalysisConstant.REGISTERED_RESI: |
|
|
|
dimInitResultDto.setValue(userSubGridResDTO.getResiTotal()); |
|
|
|
break; |
|
|
|
case UserAnalysisConstant.WARMHEARTED: |
|
|
|
dimInitResultDto.setValue(userSubGridResDTO.getWarmHeartedTotal()); |
|
|
|
break; |
|
|
|
case UserAnalysisConstant.PARTYMEMBER: |
|
|
|
dimInitResultDto.setValue(userSubGridResDTO.getPartymemberTotal()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!flag){ |
|
|
|
logger.error(String.format("直属网格注册用户数缺少记录:date_id=%s,gridId=%s",formDTO.getDateId(),dimInitResultDto.getGridId())); |
|
|
|
} |
|
|
|
} |
|
|
|
//返回集合按照total降序排序
|
|
|
|
List<UserSubGridResultDTO> returnList = dimList.stream().sorted(Comparator.comparing(UserSubGridResultDTO::getTotal)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
return returnList; |
|
|
|
} |
|
|
|
|
|
|
|
private List<UserSubGridResultDTO> initUserSubGridResultDTO(String myAgencyId) { |
|
|
|
List<UserSubGridResultDTO> list=new ArrayList<>(); |
|
|
|
List<DimGridDTO> gridList=userAnalysisDao.selectSubGridList(myAgencyId); |
|
|
|
for(DimGridDTO grid:gridList){ |
|
|
|
//居民
|
|
|
|
UserSubGridResultDTO resi=new UserSubGridResultDTO(); |
|
|
|
resi.setGridId(grid.getId()); |
|
|
|
resi.setName(grid.getGridName()); |
|
|
|
resi.setValue(NumConstant.ZERO); |
|
|
|
resi.setType(UserAnalysisConstant.REGISTERED_RESI); |
|
|
|
resi.setTotal(NumConstant.ZERO); |
|
|
|
list.add(resi); |
|
|
|
//热心居民
|
|
|
|
UserSubGridResultDTO warm=new UserSubGridResultDTO(); |
|
|
|
warm.setGridId(grid.getId()); |
|
|
|
warm.setName(grid.getGridName()); |
|
|
|
warm.setValue(NumConstant.ZERO); |
|
|
|
warm.setType(UserAnalysisConstant.WARMHEARTED); |
|
|
|
warm.setTotal(NumConstant.ZERO); |
|
|
|
list.add(warm); |
|
|
|
//党员
|
|
|
|
UserSubGridResultDTO party=new UserSubGridResultDTO(); |
|
|
|
party.setGridId(grid.getId()); |
|
|
|
party.setName(grid.getGridName()); |
|
|
|
party.setValue(NumConstant.ZERO); |
|
|
|
party.setType(UserAnalysisConstant.PARTYMEMBER); |
|
|
|
party.setTotal(NumConstant.ZERO); |
|
|
|
list.add(party); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|