|
|
@ -1,10 +1,8 @@ |
|
|
|
package com.epmet.datareport.service.screen.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.datareport.dao.screen.ScreenDifficultyDataDao; |
|
|
|
import com.epmet.datareport.dao.screen.ScreenPartyUserRankDataDao; |
|
|
|
import com.epmet.datareport.dao.screen.ScreenUserJoinDao; |
|
|
|
import com.epmet.datareport.dao.screen.ScreenUserTotalDataDao; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.datareport.dao.screen.*; |
|
|
|
import com.epmet.datareport.service.screen.GrassRootsGovernService; |
|
|
|
import com.epmet.datareport.utils.DateUtils; |
|
|
|
import com.epmet.datareport.utils.ModuleConstant; |
|
|
@ -12,7 +10,6 @@ import com.epmet.screen.dto.form.AgencyAndNumFormDTO; |
|
|
|
import com.epmet.screen.dto.form.AgencyFormDTO; |
|
|
|
import com.epmet.screen.dto.form.AgencyNumTypeParamFormDTO; |
|
|
|
import com.epmet.screen.dto.result.*; |
|
|
|
import com.github.pagehelper.Page; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -21,6 +18,7 @@ import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -42,6 +40,8 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
private DateUtils dateUtils; |
|
|
|
@Autowired |
|
|
|
private ScreenUserTotalDataDao screenUserTotalDataDao; |
|
|
|
@Autowired |
|
|
|
private ScreenGovernRankDataDao screenGovernRankDataDao; |
|
|
|
/** |
|
|
|
* @Description 1、热心市民积分排行 |
|
|
|
* @NEI https://nei.netease.com/interface/detail/req/?pid=57068&id=321544
|
|
|
@ -78,7 +78,6 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
if(null == param.getTopNum()){ |
|
|
|
param.setTopNum(NumConstant.TWO); |
|
|
|
} |
|
|
|
|
|
|
|
PageHelper.startPage(NumConstant.ONE,param.getTopNum()); |
|
|
|
List<DifficultProjectResultDTO> result = screenDifficultyDataDao.selectDifficulty(param.getAgencyId(),param.getType()); |
|
|
|
if(null == result) return new ArrayList<>(); |
|
|
@ -96,32 +95,19 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public PublicPartiProfileResultDTO publicPartiProfile(AgencyFormDTO param) { |
|
|
|
|
|
|
|
String monthId = dateUtils.getPreviousMonthId(); |
|
|
|
PublicPartiProfileResultDTO latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId); |
|
|
|
if(null == latest) return null; |
|
|
|
if(null == latest.getTotal()) latest.setTotal(NumConstant.ZERO); |
|
|
|
if(null == latest.getAverageJoin()) latest.setAverageJoin(NumConstant.ZERO); |
|
|
|
PublicPartiProfileResultDTO previous = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), dateUtils.getPreviousMonthIdByDest(null,monthId)); |
|
|
|
Integer preTotal ; Integer preAvgJoin ; |
|
|
|
if(null == previous){ preTotal = NumConstant.ZERO; preAvgJoin = NumConstant.ZERO;} |
|
|
|
preTotal = null == previous.getTotal() ? NumConstant.ZERO : previous.getTotal(); |
|
|
|
preAvgJoin = null == previous.getAverageJoin() ? NumConstant.ZERO : previous.getAverageJoin(); |
|
|
|
if(latest.getTotal() >= preTotal){ |
|
|
|
latest.setMonthTrend("incr"); |
|
|
|
latest.setMonthIncr(convertPercentStr(new BigDecimal((latest.getTotal() - preTotal)/preTotal))); |
|
|
|
} |
|
|
|
if(latest.getAverageJoin() >= preAvgJoin){ |
|
|
|
latest.setJoinCompareLatestTrend("incr"); |
|
|
|
latest.setJoinCompareLatestMonth(convertPercentStr(new BigDecimal((latest.getAverageJoin() - preAvgJoin)/preAvgJoin))); |
|
|
|
} |
|
|
|
latest.setAverageIssue(screenUserTotalDataDao.selectAvgIssue(param.getAgencyId())); |
|
|
|
latest.setIssueCompareLatestTrend("incr"); |
|
|
|
latest.setIssueCompareLastestMonth(convertPercentStr(null)); |
|
|
|
return null; |
|
|
|
UserJoinIndicatorGrowthRateResultDTO latest = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId); |
|
|
|
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(),NumConstant.ZERO)); |
|
|
|
result.setIssueCompareLatestMonth(convertPercentStr(latest.getIssueCompareLatestMonth(),NumConstant.ZERO)); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 公众参与-排行榜 |
|
|
|
* @Description 4、公众参与-排行榜 |
|
|
|
* @NEI https://nei.netease.com/interface/detail/?pid=57068&id=321978
|
|
|
|
* @param param |
|
|
|
* @return |
|
|
@ -130,7 +116,7 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<PublicPartiRankResultDTO> publicPartiRank(AgencyAndNumFormDTO param) { |
|
|
|
|
|
|
|
if(null == param.getTopNum()) param.setTopNum(NumConstant.TWO); |
|
|
|
if(NumConstant.ZERO == param.getTopNum()) param.setTopNum(NumConstant.MAX); |
|
|
|
PageHelper.startPage(NumConstant.ONE,param.getTopNum()); |
|
|
|
List<PublicPartiRankResultDTO> result = screenUserTotalDataDao.selectUserTotalData(param.getAgencyId()); |
|
|
@ -138,12 +124,99 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 5、治理能力榜单 |
|
|
|
* @NEI https://nei.netease.com/interface/detail/req/?pid=57068&id=321627
|
|
|
|
* @param param |
|
|
|
* @return |
|
|
|
* @author wangc |
|
|
|
* @date 2020.08.20 17:46 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<GovernCapacityRankResultDTO> governCapacityRank(AgencyAndNumFormDTO param) { |
|
|
|
if(null == param.getTopNum()) param.setTopNum(NumConstant.FIVE); |
|
|
|
if(NumConstant.ZERO == param.getTopNum()) param.setTopNum(NumConstant.MAX); |
|
|
|
PageHelper.startPage(NumConstant.ONE,param.getTopNum()); |
|
|
|
List<GovernCapacityResultDTO> orderList = |
|
|
|
screenGovernRankDataDao.selectGovernCapacityRatio(dateUtils.getPreviousMonthId(),param.getAgencyId()); |
|
|
|
if(null == orderList || orderList.isEmpty()) return new ArrayList<>(); |
|
|
|
List<GovernCapacityRankResultDTO> result = new LinkedList<>(); |
|
|
|
orderList.forEach(o -> { |
|
|
|
GovernCapacityRankResultDTO rank = new GovernCapacityRankResultDTO(); |
|
|
|
rank.setAgencyName(o.getAgencyName()); |
|
|
|
rank.setGovernRatio(convertPercentStr(new BigDecimal(o.getGovernRatio()))); |
|
|
|
rank.setResolvedRatio(convertPercentStr(new BigDecimal(o.getResolvedRatio()))); |
|
|
|
rank.setResponseRatio(convertPercentStr(new BigDecimal(o.getResponseRatio()))); |
|
|
|
rank.setSatisfactionRatio(convertPercentStr(new BigDecimal(o.getSatisfactionRatio()))); |
|
|
|
result.add(rank); |
|
|
|
}); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 6、公众参与-柱状折线图 |
|
|
|
* @NEI https://nei.netease.com/interface/detail/req/?pid=57068&id=322434
|
|
|
|
* @param param |
|
|
|
* @return |
|
|
|
* @author wangc |
|
|
|
* @date 2020.08.21 09:58 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public PublicPartiChartResultDTO publicPartiChart(AgencyFormDTO param) { |
|
|
|
Map<String,String> Xaxis = dateUtils.getXpro(); |
|
|
|
List<UserJoinMonthlyResultDTO> monthlyData = screenUserJoinDao.selectUserJoinDataMonthly(param.getAgencyId(),Xaxis.keySet().iterator().next()); |
|
|
|
PublicPartiChartResultDTO result = new PublicPartiChartResultDTO(); |
|
|
|
result.setXAxis(Xaxis.values().stream().collect(Collectors.toList())); |
|
|
|
List<Integer> defaultData = new LinkedList<>(); |
|
|
|
for(int i = NumConstant.ZERO ; i < NumConstant.TWELVE ; i++){ |
|
|
|
defaultData.add(NumConstant.ZERO); |
|
|
|
} |
|
|
|
if(null == monthlyData || monthlyData.isEmpty()){ |
|
|
|
result.setAverageJoinNumList(defaultData); |
|
|
|
result.setJoinUserNumList(defaultData); |
|
|
|
result.setOrganizeNumList(defaultData); |
|
|
|
return result; |
|
|
|
} |
|
|
|
result.setOrganizeNumList(new ArrayList<>()); |
|
|
|
result.setJoinUserNumList(new ArrayList<>()); |
|
|
|
result.setAverageJoinNumList(new ArrayList<>()); |
|
|
|
Map<String,List<UserJoinMonthlyResultDTO>> dataMap = monthlyData.stream().collect(Collectors.groupingBy(UserJoinMonthlyResultDTO :: getMonthId)); |
|
|
|
Xaxis.keySet().stream().forEach(monthId -> { |
|
|
|
List<UserJoinMonthlyResultDTO> data = dataMap.get(monthId); |
|
|
|
if(null == data || data.isEmpty()){ |
|
|
|
result.getOrganizeNumList().add(NumConstant.ZERO); |
|
|
|
result.getJoinUserNumList().add(NumConstant.ZERO); |
|
|
|
result.getAverageJoinNumList().add(NumConstant.ZERO); |
|
|
|
}else{ |
|
|
|
Integer o = NumConstant.ZERO; |
|
|
|
Integer j = NumConstant.ZERO; |
|
|
|
Integer a = NumConstant.ZERO; |
|
|
|
for(UserJoinMonthlyResultDTO unit : data){ |
|
|
|
o = null == unit.getOrganizeNum() ? NumConstant.ZERO : o + unit.getOrganizeNum(); |
|
|
|
j = null == unit.getJoinUserNum() ? NumConstant.ZERO : o + unit.getJoinUserNum(); |
|
|
|
a = null == unit.getAverageJoinNum() ? NumConstant.ZERO : o + unit.getAverageJoinNum(); |
|
|
|
} |
|
|
|
result.getOrganizeNumList().add(o); |
|
|
|
result.getJoinUserNumList().add(j); |
|
|
|
result.getAverageJoinNumList().add(a); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private String convertPercentStr(BigDecimal percent){ |
|
|
|
if(null == percent || BigDecimal.ZERO == percent) return "0.00%"; |
|
|
|
String percentStr = percent.setScale(NumConstant.TWO, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); |
|
|
|
return percentStr.concat(ModuleConstant.SYMBOL_PERCENT); |
|
|
|
} |
|
|
|
|
|
|
|
private String convertPercentStr(BigDecimal percent,Integer digits){ |
|
|
|
if(null == percent) percent = BigDecimal.ZERO; |
|
|
|
String percentStr = percent.setScale(digits, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); |
|
|
|
return percentStr.concat(ModuleConstant.SYMBOL_PERCENT); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|