From 67ee6c6560319abbbdbfed8d2b9323730a80c2c0 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 9 Jul 2021 16:40:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E9=95=BF=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/GovernConstant.java | 16 ++++ .../screen/ScreenUserJoinDao.java | 10 +++ .../impl/PublicPartExtractServiceImpl.java | 83 ++++++++++++++++++- .../screen/ScreenUserJoinService.java | 10 +++ .../impl/ScreenUserJoinServiceImpl.java | 13 +++ .../screen/ScreenUserJoinDao.xml | 10 +++ 6 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/GovernConstant.java diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/GovernConstant.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/GovernConstant.java new file mode 100644 index 0000000000..9219f505a1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/GovernConstant.java @@ -0,0 +1,16 @@ +package com.epmet.constant; + +/** + * @Author zxc + * @DateTime 2021/7/9 3:24 下午 + * @DESC + */ +public interface GovernConstant { + + /** + * 增长:incr;下降:decr; 相等 :eq; + */ + String INCR = "incr"; + String DECR = "decr"; + String EQ = "eq"; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserJoinDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserJoinDao.java index ba45d011da..ada3123821 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserJoinDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenUserJoinDao.java @@ -83,4 +83,14 @@ public interface ScreenUserJoinDao extends BaseDao { * @Date 10:52 2020-08-18 **/ void batchInsertUserJoin(@Param("list") List list, @Param("customerId")String customerId); + + /** + * @Description 根据月份查询screenUserJoin + * @Param customerId + * @Param monthId + * @Param flag :agency : grid + * @author zxc + * @date 2021/7/9 3:13 下午 + */ + List selectScreenUserJoin(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("flag")String flag); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java index 5e96035ae9..9260f204e5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.GovernConstant; import com.epmet.constant.OrgTypeConstant; import com.epmet.constant.ProjectConstant; import com.epmet.dto.extract.form.ExtractScreenFormDTO; @@ -407,7 +408,8 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { entity.setAvgJoin(realJoinCount.divide(avgFz, NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); } } - screenUserJoinService.deleteAndInsertBatch(formDTO, new ArrayList<>(insertMap.values()),OrgTypeConstant.GRID); + ArrayList dispose = dispose(formDTO, insertMap, OrgTypeConstant.GRID); + screenUserJoinService.deleteAndInsertBatch(formDTO, dispose,OrgTypeConstant.GRID); } /** @@ -492,7 +494,84 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { } }); } - screenUserJoinService.deleteAndInsertBatch(formDTO, new ArrayList<>(insertMap.values()),OrgTypeConstant.AGENCY); + ArrayList dispose = dispose(formDTO, insertMap, OrgTypeConstant.AGENCY); + screenUserJoinService.deleteAndInsertBatch(formDTO, dispose,OrgTypeConstant.AGENCY); } + public ArrayList dispose(ExtractScreenFormDTO formDTO,Map insertMap,String flag) { + String beforeNMonthByMonth = DateUtils.getBeforeNMonthByMonth(NumConstant.ONE, formDTO.getMonthId()); + List screenUserJoinEntities = screenUserJoinService.selectScreenUserJoin(formDTO.getCustomerId(), beforeNMonthByMonth, flag); + ArrayList insertList = new ArrayList<>(insertMap.values()); + if (CollectionUtils.isEmpty(screenUserJoinEntities)) { + insertList.forEach(l -> { + // 总的参与次数较上月增长率 + if (l.getJoinTotal().equals(NumConstant.ZERO)) { + l.setJoinTotalUpFlag(GovernConstant.EQ); + l.setJoinTotalUpRate(NumConstant.ZERO_DECIMAL); + } else if (l.getJoinTotal() > NumConstant.ZERO) { + l.setJoinTotalUpFlag(GovernConstant.INCR); + l.setJoinTotalUpRate(NumConstant.ONE_HUNDRED_DECIMAL); + } + // 人均议题较上月增长率 + if (l.getAvgIssue().equals(NumConstant.ZERO_DECIMAL)) { + l.setAvgIssueUpFlag(GovernConstant.EQ); + l.setAvgIssueUpRate(NumConstant.ZERO_DECIMAL); + } else { + l.setAvgIssueUpFlag(GovernConstant.INCR); + l.setAvgIssueUpRate(NumConstant.ONE_HUNDRED_DECIMAL); + } + // 平均参与度较上月增长率 + if (l.getAvgJoin().equals(NumConstant.ZERO_DECIMAL)) { + l.setAgvgJoinUpFlag(GovernConstant.EQ); + l.setAgvgJoinUpRate(NumConstant.ZERO_DECIMAL); + } else { + l.setAgvgJoinUpFlag(GovernConstant.INCR); + l.setAgvgJoinUpRate(NumConstant.ONE_HUNDRED_DECIMAL); + } + }); + } else { + insertList.forEach(l -> { + screenUserJoinEntities.forEach(s -> { + if (l.getOrgId().equals(s.getOrgId())) { + // 总的参与次数较上月增长率 + if (l.getJoinTotal() > s.getJoinTotal()) { + l.setJoinTotalUpFlag(GovernConstant.INCR); + l.setJoinTotalUpRate(new BigDecimal(((l.getJoinTotal() - s.getJoinTotal()) / s.getJoinTotal()) * NumConstant.ONE_HUNDRED).setScale(NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); + } else if (l.getJoinTotal() < s.getJoinTotal()) { + l.setJoinTotalUpFlag(GovernConstant.DECR); + l.setJoinTotalUpRate(new BigDecimal(((l.getJoinTotal() - s.getJoinTotal()) / s.getJoinTotal()) * NumConstant.ONE_HUNDRED).setScale(NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); + } else { + l.setJoinTotalUpFlag(GovernConstant.EQ); + l.setJoinTotalUpRate(NumConstant.ZERO_DECIMAL); + } + // 人均议题较上月增长率 + Integer re = l.getAvgIssue().compareTo(s.getAvgIssue()); + if (re.equals(NumConstant.ONE)) { + l.setAvgIssueUpFlag(GovernConstant.INCR); + l.setAvgIssueUpRate(l.getAvgIssue().subtract(s.getAvgIssue()).divide(s.getAvgIssue()).multiply(NumConstant.ONE_HUNDRED_DECIMAL).setScale(NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); + } else if (re.equals(NumConstant.ONE_NEG)) { + l.setAvgIssueUpFlag(GovernConstant.DECR); + l.setAvgIssueUpRate(l.getAvgIssue().subtract(s.getAvgIssue()).divide(s.getAvgIssue()).multiply(NumConstant.ONE_HUNDRED_DECIMAL).setScale(NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); + } else { + l.setAvgIssueUpFlag(GovernConstant.EQ); + l.setAvgIssueUpRate(NumConstant.ZERO_DECIMAL); + } + // 平均参与度较上月增长率 + Integer avgJoinRe = l.getAvgJoin().compareTo(s.getAvgJoin()); + if (avgJoinRe.equals(NumConstant.ONE)) { + l.setAgvgJoinUpFlag(GovernConstant.INCR); + l.setAgvgJoinUpRate(l.getAvgJoin().subtract(s.getAvgJoin()).divide(s.getAvgJoin()).multiply(NumConstant.ONE_HUNDRED_DECIMAL).setScale(NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); + } else if (avgJoinRe.equals(NumConstant.ONE_NEG)) { + l.setAvgIssueUpFlag(GovernConstant.DECR); + l.setAgvgJoinUpRate(l.getAvgJoin().subtract(s.getAvgJoin()).divide(s.getAvgJoin()).multiply(NumConstant.ONE_HUNDRED_DECIMAL).setScale(NumConstant.FOUR, BigDecimal.ROUND_HALF_UP)); + } else { + l.setAvgIssueUpFlag(GovernConstant.EQ); + l.setAgvgJoinUpRate(NumConstant.ZERO_DECIMAL); + } + } + }); + }); + } + return insertList; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserJoinService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserJoinService.java index dcdf848174..e3574393e8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserJoinService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenUserJoinService.java @@ -42,4 +42,14 @@ public interface ScreenUserJoinService extends BaseService * @date 2020/9/27 4:40 下午 */ Boolean deleteAndInsertBatch(ExtractScreenFormDTO formDTO, List list,String delFlag); + + /** + * @Description 根据月份查询screenUserJoin + * @Param customerId + * @Param monthId + * @Param flag :agency : grid + * @author zxc + * @date 2021/7/9 3:13 下午 + */ + List selectScreenUserJoin(String customerId,String monthId,String flag); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserJoinServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserJoinServiceImpl.java index 978ce14992..97b976e475 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserJoinServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenUserJoinServiceImpl.java @@ -124,6 +124,19 @@ public class ScreenUserJoinServiceImpl extends BaseServiceImpl selectScreenUserJoin(String customerId, String monthId, String flag) { + return baseDao.selectScreenUserJoin(customerId, monthId, flag); + } + /** * 计算 本月数值 相较于 上月数值,的增长率 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserJoinDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserJoinDao.xml index 0fc7db5b18..42cc5ffba3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserJoinDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenUserJoinDao.xml @@ -100,4 +100,14 @@ + + + +