diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AgencyFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AgencyFormDTO.java index 166c9c2aa9..fcba02911c 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AgencyFormDTO.java +++ b/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; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java index 94e4f20546..3e02aa4e96 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java +++ b/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; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java index 0cdb93a9c7..a048bf2c3e 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java +++ b/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> crmResp = crmClient.getAllSubCustomerIds(agencyInfo.getCustomerId()); - List 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); - //保证获取公众参与概率数据的最大可能性 - 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); - } + // 总参与数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"); - 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); result.setMonthIncr(convertPercentStr(latest.getMonthIncr(), NumConstant.ZERO)); result.setJoinCompareLatestMonth(convertPercentStr(latest.getJoinCompareLatestMonth().abs(), NumConstant.ZERO)); diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java index bfc46d03bd..a087e1c3c6 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java +++ b/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()); } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml index de0473571e..2818ea0714 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml @@ -28,36 +28,22 @@