|
|
@ -133,30 +133,57 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
* @author wangc |
|
|
|
* @date 2020.08.20 14:37 |
|
|
|
**/ |
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) |
|
|
|
@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()|| org.apache.commons.collections4.CollectionUtils.isEmpty(crmResp.getData())) {subCustomers = null ;} |
|
|
|
else {subCustomers = crmResp.getData();} |
|
|
|
String monthId = dateUtils.getPreviousMonthId(NumConstant.ONE); |
|
|
|
UserJoinIndicatorGrowthRateResultDTO latest = new UserJoinIndicatorGrowthRateResultDTO(); |
|
|
|
if (StringUtils.isNotBlank(param.getAreaCode()) && "370124".equals(param.getAreaCode())) { |
|
|
|
latest= screenUserJoinDao.selectUserJoinDataByAreaCode(param.getAreaCode(), monthId); |
|
|
|
if (null == latest) { |
|
|
|
log.warn(String.format("平阴县查询screen_user_join表为空,monthId:%s", monthId)); |
|
|
|
return new PublicPartiProfileResultDTO(); |
|
|
|
} |
|
|
|
UserJoinIndicatorGrowthRateResultDTO beforeTwoMonth = screenUserJoinDao.selectUserJoinDataByAreaCode(param.getAreaCode(), dateUtils.getPreviousMonthId(NumConstant.TWO)); |
|
|
|
if (null == beforeTwoMonth) { |
|
|
|
log.warn(String.format("平阴县查询screen_user_join表为空,monthId:%s",dateUtils.getPreviousMonthId(NumConstant.TWO))); |
|
|
|
}else{ |
|
|
|
//举例,today is 20210707 , latest是06月份的数据,beforeTwoMonth是05月份的数据
|
|
|
|
|
|
|
|
String monthId = dateUtils.getCurrentMonthId(); |
|
|
|
UserJoinIndicatorGrowthRateResultDTO latest = CollectionUtils.isEmpty(subCustomers) ||StringUtils.isBlank(agencyInfo.getAreaCode())? |
|
|
|
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) : |
|
|
|
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId); |
|
|
|
// 总参与数6月份比5月份增加了?
|
|
|
|
int incrTotal = latest.getTotal() - beforeTwoMonth.getTotal(); |
|
|
|
// 总参与数月增长:增加的占5月份的占比???
|
|
|
|
BigDecimal monthIncr = BigDecimal.valueOf(incrTotal / beforeTwoMonth.getTotal()); |
|
|
|
latest.setMonthIncr(monthIncr); |
|
|
|
latest.setMonthTrend(monthIncr.compareTo(BigDecimal.ZERO) > 0 ? "incr" : "decr"); |
|
|
|
|
|
|
|
//人均议题数6月份比五月份增加了?
|
|
|
|
BigDecimal issueIncrTotal = latest.getAverageIssue().subtract(beforeTwoMonth.getAverageIssue()); |
|
|
|
//人均议题数月增长:增加的占5月份的占比???
|
|
|
|
BigDecimal issueCompareLatestMonth = issueIncrTotal.divide(beforeTwoMonth.getAverageIssue()); |
|
|
|
latest.setIssueCompareLatestMonth(issueCompareLatestMonth); |
|
|
|
latest.setIssueCompareLatestTrend(issueCompareLatestMonth.compareTo(BigDecimal.ZERO) > 0 ? "incr" : "decr"); |
|
|
|
|
|
|
|
// 平均参与度6月份比5月份增加了?
|
|
|
|
BigDecimal incrJoinCompareLatestMonth=latest.getJoinCompareLatestMonth().subtract(beforeTwoMonth.getJoinCompareLatestMonth()); |
|
|
|
//平均参与度月增长:增加的占5月份的占比???
|
|
|
|
BigDecimal joinCompareLatestMonth=incrJoinCompareLatestMonth.divide(beforeTwoMonth.getJoinCompareLatestMonth()); |
|
|
|
latest.setJoinCompareLatestMonth(joinCompareLatestMonth); |
|
|
|
latest.setJoinCompareLatestTrend(joinCompareLatestMonth.compareTo(BigDecimal.ZERO) > 0 ? "incr" : "decr"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId); |
|
|
|
//保证获取公众参与概率数据的最大可能性
|
|
|
|
int time = NumConstant.TWELVE; |
|
|
|
while ((null == latest || latest.getId() == null) && time > NumConstant.ONE) { |
|
|
|
time--; |
|
|
|
monthId = dateUtils.getPreviousMonthIdByDest(null, monthId); |
|
|
|
latest = CollectionUtils.isEmpty(subCustomers)||StringUtils.isBlank(agencyInfo.getAreaCode()) ? |
|
|
|
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) : |
|
|
|
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId); |
|
|
|
latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null == latest) { |
|
|
|
return new PublicPartiProfileResultDTO(); |
|
|
|
} |
|
|
|
|
|
|
|
if (null == latest) return new PublicPartiProfileResultDTO(); |
|
|
|
PublicPartiProfileResultDTO result = ConvertUtils.sourceToTarget(latest, PublicPartiProfileResultDTO.class); |
|
|
|
result.setMonthIncr(convertPercentStr(latest.getMonthIncr(), NumConstant.ZERO)); |
|
|
|
result.setJoinCompareLatestMonth(convertPercentStr(latest.getJoinCompareLatestMonth().abs(), NumConstant.ZERO)); |
|
|
|