Browse Source

公众参与概况publicpartiprofile接口调整

dev_shibei_match
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. 67
      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) @NotBlank(message = "机关Id不能为空" , groups = CommonAgencyIdGroup.class)
private String agencyId; 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 * @Description 用户参与各项指标以及增长查询结果dto
* @ClassName UserJoinIndicatorGrowthRateResultDTO * @ClassName UserJoinIndicatorGrowthRateResultDTO
* @Auth wangc * @author wangc
* @Date 2020-08-21 16:07 * @Date 2020-08-21 16:07
*/ */
@Data @Data
@ -16,25 +16,33 @@ public class UserJoinIndicatorGrowthRateResultDTO implements Serializable {
private static final long serialVersionUID = -8830240350298414599L; private static final long serialVersionUID = -8830240350298414599L;
private String id; private String id;
/**
* 总参与数
* */
private Integer total; private Integer total;
/**
* 总参与数月增长
* */
private BigDecimal monthIncr; private BigDecimal monthIncr;
/** /**
* incr上升, decr下降 * 总参与数incr上升, decr下降
* */ * */
private String monthTrend; private String monthTrend;
/**
* 人均议题
* */
private BigDecimal averageIssue; private BigDecimal averageIssue;
/** /**
* 较上月百分比 * 人均议题较上月百分比
* */ * */
private BigDecimal issueCompareLatestMonth; private BigDecimal issueCompareLatestMonth;
/** /**
* 较上月趋势incr上升decr下降 * 人均议题较上月趋势incr上升decr下降
* */ * */
private String issueCompareLatestTrend; private String issueCompareLatestTrend;
@ -43,7 +51,13 @@ public class UserJoinIndicatorGrowthRateResultDTO implements Serializable {
*/ */
private BigDecimal averageJoin; private BigDecimal averageJoin;
/**
* 平均参与度: 较上月百分比
*/
private BigDecimal joinCompareLatestMonth; private BigDecimal joinCompareLatestMonth;
/**
* 平均参与度较上月趋势incr上升decr下降
*/
private String joinCompareLatestTrend; private String joinCompareLatestTrend;
} }

67
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 * @author wangc
* @date 2020.08.20 14:37 * @date 2020.08.20 14:37
**/ **/
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) @DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override @Override
public PublicPartiProfileResultDTO publicPartiProfile(AgencyFormDTO param) { public PublicPartiProfileResultDTO publicPartiProfile(AgencyFormDTO param) {
ScreenCustomerAgencyDTO agencyInfo = agencyInfo(param.getAgencyId()); String monthId = dateUtils.getPreviousMonthId(NumConstant.ONE);
Result<List<String>> crmResp = crmClient.getAllSubCustomerIds(agencyInfo.getCustomerId()); UserJoinIndicatorGrowthRateResultDTO latest = new UserJoinIndicatorGrowthRateResultDTO();
List<String> subCustomers; if (StringUtils.isNotBlank(param.getAreaCode()) && "370124".equals(param.getAreaCode())) {
if(null == crmResp || !crmResp.success()|| org.apache.commons.collections4.CollectionUtils.isEmpty(crmResp.getData())) {subCustomers = null ;} latest= screenUserJoinDao.selectUserJoinDataByAreaCode(param.getAreaCode(), monthId);
else {subCustomers = crmResp.getData();} 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(); // 总参与数6月份比5月份增加了?
UserJoinIndicatorGrowthRateResultDTO latest = CollectionUtils.isEmpty(subCustomers) ||StringUtils.isBlank(agencyInfo.getAreaCode())? int incrTotal = latest.getTotal() - beforeTwoMonth.getTotal();
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) : // 总参与数月增长:增加的占5月份的占比???
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId); BigDecimal monthIncr = BigDecimal.valueOf(incrTotal / beforeTwoMonth.getTotal());
//保证获取公众参与概率数据的最大可能性 latest.setMonthIncr(monthIncr);
int time = NumConstant.TWELVE; latest.setMonthTrend(monthIncr.compareTo(BigDecimal.ZERO) > 0 ? "incr" : "decr");
while ((null == latest || latest.getId() == null) && time > NumConstant.ONE) {
time--; //人均议题数6月份比五月份增加了?
monthId = dateUtils.getPreviousMonthIdByDest(null, monthId); BigDecimal issueIncrTotal = latest.getAverageIssue().subtract(beforeTwoMonth.getAverageIssue());
latest = CollectionUtils.isEmpty(subCustomers)||StringUtils.isBlank(agencyInfo.getAreaCode()) ? //人均议题数月增长:增加的占5月份的占比???
screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId) : BigDecimal issueCompareLatestMonth = issueIncrTotal.divide(beforeTwoMonth.getAverageIssue());
screenUserJoinDao.selectUserJoinDataByAreaCode(agencyInfo.getAreaCode(),monthId); latest.setIssueCompareLatestMonth(issueCompareLatestMonth);
} latest.setIssueCompareLatestTrend(issueCompareLatestMonth.compareTo(BigDecimal.ZERO) > 0 ? "incr" : "decr");
if (null == latest) return new PublicPartiProfileResultDTO(); // 平均参与度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 = screenUserJoinDao.selectUserJoinData(param.getAgencyId(), monthId);
}
}
if (null == latest) {
return new PublicPartiProfileResultDTO();
}
PublicPartiProfileResultDTO result = ConvertUtils.sourceToTarget(latest, PublicPartiProfileResultDTO.class); PublicPartiProfileResultDTO result = ConvertUtils.sourceToTarget(latest, PublicPartiProfileResultDTO.class);
result.setMonthIncr(convertPercentStr(latest.getMonthIncr(), NumConstant.ZERO)); result.setMonthIncr(convertPercentStr(latest.getMonthIncr(), NumConstant.ZERO));
result.setJoinCompareLatestMonth(convertPercentStr(latest.getJoinCompareLatestMonth().abs(), 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 * @Description 前n个月
* @param * @param beforeMonthNum
* @return * @return
* @author wangc * @author wangc
* @date 2020.08.20 10:19 * @date 2020.08.20 10:19
**/ **/
public String getPreviousMonthId(){ public String getPreviousMonthId(int beforeMonthNum){
SimpleDateFormat format = new SimpleDateFormat("yyyyMM"); SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date()); // 设置为当前时间 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()); 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 id="selectUserJoinDataByAreaCode" resultType="com.epmet.evaluationindex.screen.dto.result.UserJoinIndicatorGrowthRateResultDTO">
SELECT SELECT
scj.ID, ifnull(sum(suj.JOIN_TOTAL),0) as total,
IFNULL(avg( scj.JOIN_TOTAL ),0) AS total, 0 as monthIncr,
IFNULL(ROUND( avg( scj.AVG_JOIN ), 1 ),0) AS averageJoin, ''as monthTrend,
IFNULL(avg( scj.JOIN_TOTAL_UP_RATE ),0) AS monthIncr, round(IFNULL(sum(suj.avg_issue_fz)/sum(suj.avg_issue_fm),0)) as averageIssue,
(case when IFNULL(avg( scj.JOIN_TOTAL_UP_RATE ),0) &gt;0 then 'incr' 0 as issueCompareLatestMonth,
when IFNULL(avg( scj.JOIN_TOTAL_UP_RATE ),0) &lt; 0 then 'decr' '' as issueCompareLatestTrend,
else 'eq' round(ifnull(sum(suj.avg_join_fz)/sum(suj.avg_join_fm),0))as averageJoin,
end )as monthTrend, 0 as joinCompareLatestMonth,
ROUND( IFNULL(avg( scj.AVG_ISSUE ),0), 1 ) AS averageIssue, '' as joinCompareLatestTrend
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
FROM FROM
screen_user_join scj screen_user_join suj
LEFT JOIN screen_customer_agency agency ON scj.org_id = agency.agency_id INNER JOIN screen_customer_agency sca ON ( suj.ORG_ID = sca.AGENCY_ID AND sca.DEL_FLAG = '0' )
WHERE WHERE
scj.DEL_FLAG = '0' suj.ORG_TYPE = 'agency'
AND scj.MONTH_ID = #{monthId} AND sca.PARENT_AREA_CODE = #{areaCode}
AND agency.PARENT_AREA_CODE =#{areaCode} AND suj.MONTH_ID = #{monthId}
</select> </select>

Loading…
Cancel
Save