|
|
@ -3,16 +3,20 @@ package com.epmet.datareport.service.evaluationindex.screen.impl; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.datareport.dao.evaluationindex.screen.*; |
|
|
|
import com.epmet.datareport.service.evaluationindex.screen.GrassRootsGovernService; |
|
|
|
import com.epmet.datareport.utils.DateUtils; |
|
|
|
import com.epmet.datareport.utils.ModuleConstant; |
|
|
|
import com.epmet.dto.result.ScreenCustomerAgencyDTO; |
|
|
|
import com.epmet.evaluationindex.screen.dto.form.AgencyAndNumFormDTO; |
|
|
|
import com.epmet.evaluationindex.screen.dto.form.AgencyFormDTO; |
|
|
|
import com.epmet.evaluationindex.screen.dto.form.AgencyNumTypeParamFormDTO; |
|
|
|
import com.epmet.evaluationindex.screen.dto.result.*; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -48,6 +52,10 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
private ScreenGovernRankDataDao screenGovernRankDataDao; |
|
|
|
@Autowired |
|
|
|
private ScreenPublicPartiTotalDataDao screenPublicPartiTotalDataDao; |
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient crmClient; |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerAgencyDao agencyDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 1、热心市民积分排行 |
|
|
@ -110,15 +118,26 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) |
|
|
|
@Override |
|
|
|
public PublicPartiProfileResultDTO publicPartiProfile(AgencyFormDTO param) { |
|
|
|
ScreenCustomerAgencyDTO agencyInfo = agencyInfo(param.getAgencyId()); |
|
|
|
Result<List<String>> crmResp = crmClient.getAllSubCustomerIds(agencyInfo.getCustomerId()); |
|
|
|
List<String> subCustomers; |
|
|
|
if(null == crmResp || !crmResp.success()) {subCustomers = null ;} |
|
|
|
else {subCustomers = crmResp.getData();} |
|
|
|
|
|
|
|
String monthId = dateUtils.getCurrentMonthId(); |
|
|
|
UserJoinIndicatorGrowthRateResultDTO latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId); |
|
|
|
UserJoinIndicatorGrowthRateResultDTO latest = CollectionUtils.isEmpty(subCustomers) ? |
|
|
|
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) : |
|
|
|
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId, |
|
|
|
subCustomers,agencyInfo.getCustomerId()); |
|
|
|
//保证获取公众参与概率数据的最大可能性
|
|
|
|
int time = NumConstant.TWELVE; |
|
|
|
while (null == latest && time > NumConstant.ONE) { |
|
|
|
time--; |
|
|
|
monthId = dateUtils.getPreviousMonthIdByDest(null, monthId); |
|
|
|
latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId); |
|
|
|
latest = CollectionUtils.isEmpty(subCustomers) ? |
|
|
|
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) : |
|
|
|
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId, |
|
|
|
subCustomers,agencyInfo.getCustomerId()); |
|
|
|
} |
|
|
|
|
|
|
|
if (null == latest) return new PublicPartiProfileResultDTO(); |
|
|
@ -146,8 +165,18 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
if(NumConstant.ZERO == param.getTopNum()){ |
|
|
|
param.setTopNum(NumConstant.MAX); |
|
|
|
} |
|
|
|
|
|
|
|
ScreenCustomerAgencyDTO agencyInfo = agencyInfo(param.getAgencyId()) ; |
|
|
|
List<String> subCustomers; |
|
|
|
Result<List<String>> crmResp = crmClient.getAllSubCustomerIds(agencyInfo.getCustomerId()); |
|
|
|
if(null == crmResp || !crmResp.success()) {subCustomers = null ;} |
|
|
|
else {subCustomers = crmResp.getData();} |
|
|
|
PageHelper.startPage(NumConstant.ONE,param.getTopNum()); |
|
|
|
List<PublicPartiRankResultDTO> result = screenPublicPartiTotalDataDao.selectPublicPartiTotal(param.getAgencyId()); |
|
|
|
List<PublicPartiRankResultDTO> result = |
|
|
|
CollectionUtils.isEmpty(subCustomers) ? |
|
|
|
screenPublicPartiTotalDataDao.selectPublicPartiTotal(param.getAgencyId()) |
|
|
|
: screenPublicPartiTotalDataDao.selectPublicPartiTotalByAreaCode(agencyInfo.getAreaCode(),agencyInfo.getCustomerId(), |
|
|
|
subCustomers); |
|
|
|
if(null == result) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
@ -254,6 +283,18 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
return percentStr.concat(ModuleConstant.SYMBOL_PERCENT); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 通过agencyId获取机关信息 |
|
|
|
* @param agencyId |
|
|
|
* @return java.lang.String |
|
|
|
* @author wangc |
|
|
|
* @date 2021.02.25 13:46 |
|
|
|
*/ |
|
|
|
private ScreenCustomerAgencyDTO agencyInfo(String agencyId){ |
|
|
|
ScreenCustomerAgencyDTO agencyInfo = agencyDao.selectByAgencyId(agencyId); |
|
|
|
if(null == agencyInfo) throw new RenException("获取Agency信息失败"); |
|
|
|
return agencyInfo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|