Browse Source

公众参与概况publicpartiprofile接口调整

dev
yinzuomei 4 years ago
parent
commit
b7ebeb3da7
  1. 5
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AgencyFormDTO.java
  2. 24
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java
  3. 57
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java
  4. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java
  5. 42
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml

5
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AgencyFormDTO.java

@ -21,4 +21,9 @@ public class AgencyFormDTO implements Serializable {
@NotBlank(message = "机关Id不能为空" , groups = CommonAgencyIdGroup.class)
private String agencyId;
/**
* 平阴县默认穿370124,跟随8个街道点击事件传入街道的areaCode
* */
private String areaCode;
}

24
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java

@ -8,7 +8,7 @@ import java.math.BigDecimal;
/**
* @Description 用户参与各项指标以及增长查询结果dto
* @ClassName UserJoinIndicatorGrowthRateResultDTO
* @Auth wangc
* @author wangc
* @Date 2020-08-21 16:07
*/
@Data
@ -16,25 +16,33 @@ public class UserJoinIndicatorGrowthRateResultDTO implements Serializable {
private static final long serialVersionUID = -8830240350298414599L;
private String id;
/**
* 总参与数
* */
private Integer total;
/**
* 总参与数月增长
* */
private BigDecimal monthIncr;
/**
* incr上升, decr下降
* 总参与数incr上升, decr下降
* */
private String monthTrend;
/**
* 人均议题
* */
private BigDecimal averageIssue;
/**
* 较上月百分比
* 人均议题较上月百分比
* */
private BigDecimal issueCompareLatestMonth;
/**
* 较上月趋势incr上升decr下降
* 人均议题较上月趋势incr上升decr下降
* */
private String issueCompareLatestTrend;
@ -43,7 +51,13 @@ public class UserJoinIndicatorGrowthRateResultDTO implements Serializable {
*/
private BigDecimal averageJoin;
/**
* 平均参与度: 较上月百分比
*/
private BigDecimal joinCompareLatestMonth;
/**
* 平均参与度较上月趋势incr上升decr下降
*/
private String joinCompareLatestTrend;
}

57
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java

@ -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));

8
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java

@ -107,17 +107,17 @@ public class DateUtils {
}
/**
* @Description 得到上个月的monthId
* @param
* @Description 前n个月
* @param beforeMonthNum
* @return
* @author wangc
* @date 2020.08.20 10:19
**/
public String getPreviousMonthId(){
public String getPreviousMonthId(int beforeMonthNum){
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date()); // 设置为当前时间
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - beforeMonthNum); // 设置为上一个月
return format.format(calendar.getTime());
}

42
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml

@ -28,36 +28,22 @@
<!-- 根据地区码查询用户参与数据 -->
<select id="selectUserJoinDataByAreaCode" resultType="com.epmet.evaluationindex.screen.dto.result.UserJoinIndicatorGrowthRateResultDTO">
SELECT
scj.ID,
IFNULL(avg( scj.JOIN_TOTAL ),0) AS total,
IFNULL(ROUND( avg( scj.AVG_JOIN ), 1 ),0) AS averageJoin,
IFNULL(avg( scj.JOIN_TOTAL_UP_RATE ),0) AS monthIncr,
(case when IFNULL(avg( scj.JOIN_TOTAL_UP_RATE ),0) &gt;0 then 'incr'
when IFNULL(avg( scj.JOIN_TOTAL_UP_RATE ),0) &lt; 0 then 'decr'
else 'eq'
end )as monthTrend,
ROUND( IFNULL(avg( scj.AVG_ISSUE ),0), 1 ) AS averageIssue,
IFNULL(avg( scj.AVG_ISSUE_UP_RATE ),0) AS issueCompareLatestMonth,
(
case when IFNULL(avg( scj.AVG_ISSUE_UP_RATE ),0) &gt; 0 then 'incr'
when IFNULL(avg( scj.AVG_ISSUE_UP_RATE ),0) &lt; 0 then 'decr'
else 'eq'
end
)as issueCompareLatestTrend,
IFNULL(avg( scj.AGVG_JOIN_UP_RATE) ,0) AS joinCompareLatestMonth,
(
case when IFNULL(avg( scj.AGVG_JOIN_UP_RATE ),0) &gt; 0 then 'incr'
when IFNULL(avg( scj.AGVG_JOIN_UP_RATE ),0) &lt; 0 then 'decr'
else 'eq'
end
)as joinCompareLatestTrend
ifnull(sum(suj.JOIN_TOTAL),0) as total,
0 as monthIncr,
''as monthTrend,
round(IFNULL(sum(suj.avg_issue_fz)/sum(suj.avg_issue_fm),0)) as averageIssue,
0 as issueCompareLatestMonth,
'' as issueCompareLatestTrend,
round(ifnull(sum(suj.avg_join_fz)/sum(suj.avg_join_fm),0))as averageJoin,
0 as joinCompareLatestMonth,
'' as joinCompareLatestTrend
FROM
screen_user_join scj
LEFT JOIN screen_customer_agency agency ON scj.org_id = agency.agency_id
screen_user_join suj
INNER JOIN screen_customer_agency sca ON ( suj.ORG_ID = sca.AGENCY_ID AND sca.DEL_FLAG = '0' )
WHERE
scj.DEL_FLAG = '0'
AND scj.MONTH_ID = #{monthId}
AND agency.PARENT_AREA_CODE =#{areaCode}
suj.ORG_TYPE = 'agency'
AND sca.PARENT_AREA_CODE = #{areaCode}
AND suj.MONTH_ID = #{monthId}
</select>

Loading…
Cancel
Save