diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java index 75c8c1cac9..01af04ae04 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java @@ -39,6 +39,7 @@ public interface NumConstant { int SIXTY = 60; int ONE_HUNDRED = 100; BigDecimal ONE_HUNDRED_DECIMAL = new BigDecimal(100); + BigDecimal ZERO_DECIMAL = new BigDecimal(0); int ONE_THOUSAND = 1000; int MAX = 99999999; int EIGHTY_EIGHT = 88; diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java index 820d3a5447..e811c0aea0 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java @@ -19,6 +19,9 @@ public class CustomerIdAndDateIdFormDTO implements Serializable { private String customerId; - @NotBlank(message = "日期Id不能为空",groups = CustomerIdAndDateId.class) private String dateId; + + private String startDate; + + private String endDate; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java index 8796c77d71..3e2a78b716 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java @@ -263,7 +263,6 @@ public class DimController { */ @PostMapping("statsparty") public Result getPartyInfo(@RequestBody CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) { - ValidatorUtils.validateEntity(customerIdAndDateIdFormDTO, CustomerIdAndDateIdFormDTO.CustomerIdAndDateId.class); return new Result().ok(partyMemberService.statsPartyMember(customerIdAndDateIdFormDTO)); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java index 640698d058..83ad985174 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java @@ -204,6 +204,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { } } + /** + * @Description 目前只支持到区县级别,区县级以上的未实现 + * @Param monthId + * @Param customerId + * @author zxc + * @date 2020/10/20 2:59 下午 + */ @Override public void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId) { if (NumConstant.SIX != monthId.length()) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java index 0b0e1fa1ae..4215c1fe59 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java @@ -41,6 +41,7 @@ import com.epmet.service.partymember.PartyMemberService; import com.epmet.service.stats.DimCustomerPartymemberService; import com.epmet.service.stats.DimCustomerService; import com.epmet.service.stats.DimGridService; +import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -49,10 +50,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -134,32 +132,45 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl allCustomerId = dimCustomerService.getAllCustomerId(); - if (CollectionUtils.isEmpty(allCustomerId)){ + String customerIdOne = customerIdAndDateIdFormDTO.getCustomerId(); + List customerIds = new ArrayList<>(); + List dateIds = new ArrayList<>(); + if (StringUtils.isNotBlank(customerIdOne)){ + customerIds.add(customerIdOne); + }else { + customerIds = dimCustomerService.getAllCustomerId(); + } + if (CollectionUtils.isEmpty(customerIds)){ throw new RenException(StatsConstant.CUSTOMER_INFO_NULL); } - allCustomerId.forEach(customerId -> { - String dateId = customerIdAndDateIdFormDTO.getDateId(); - List partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId); - if (CollectionUtils.isEmpty(partyMemberList)){ - log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId)); - return; - } - List gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList()); - List agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds); - TimeListResultDTO timeList = DateUtils.getTimeList(dateId); - partyMemberList.forEach(party -> { - BeanUtils.copyProperties(timeList,party); - agencyInfos.forEach(agency -> { - if (party.getGridId().equals(agency.getGridId())){ - party.setAgencyId(agency.getAgencyId()); - party.setParentId(agency.getParentId()); - party.setPids(agency.getPids()); - } + if ((StringUtils.isBlank(customerIdAndDateIdFormDTO.getStartDate()) && StringUtils.isBlank(customerIdAndDateIdFormDTO.getEndDate()))){ + dateIds.add(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1))); + }else { + dateIds = DateUtils.getDaysBetween(customerIdAndDateIdFormDTO.getStartDate(), customerIdAndDateIdFormDTO.getEndDate()); + } + List finalDateIds = dateIds; + customerIds.forEach(customerId -> { + finalDateIds.forEach(dateId -> { + List partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId); + if (CollectionUtils.isEmpty(partyMemberList)){ + log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId)); + return; + } + List gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList()); + List agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds); + TimeListResultDTO timeList = DateUtils.getTimeList(dateId); + partyMemberList.forEach(party -> { + BeanUtils.copyProperties(timeList,party); + agencyInfos.forEach(agency -> { + if (party.getGridId().equals(agency.getGridId())){ + party.setAgencyId(agency.getAgencyId()); + party.setParentId(agency.getParentId()); + party.setPids(agency.getPids()); + } + }); }); + delAndInsertParty(partyMemberList,customerId,dateId); }); - delAndInsertParty(partyMemberList,customerId,dateId); }); return true; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java index 28a24f7a14..599e566540 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java @@ -3,7 +3,7 @@ package com.epmet.support.normalizing; import java.math.BigDecimal; /** - * 分值常量 + * 分值常量 归一区间 */ public class ScoreConstants { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index cfa2dc941f..900b15aaf5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java @@ -1,6 +1,7 @@ package com.epmet.support.normalizing.batch; import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.support.normalizing.BigDecimalScoreCalculator; import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; @@ -79,6 +80,7 @@ public class BatchScoreCalculator { }else { //如果不需要归一 则 直接value*权重 if (idx.isScore()) { + vo.setSampleValue(new BigDecimal(vo.getSampleValue().toString()).compareTo(NumConstant.ZERO_DECIMAL) == NumConstant.ZERO ? ScoreConstants.MIN_SCORE : new BigDecimal(vo.getSampleValue().toString())); normalizeValue = getFinalSampleValue(vo.getSampleValue(), threshold); } else { normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold)); diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/resources/数据值略小时可能的情况.txt b/epmet-module/data-statistical/data-statistical-server/src/test/java/resources/数据值略小时可能的情况.txt new file mode 100644 index 0000000000..cb778584e1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/test/java/resources/数据值略小时可能的情况.txt @@ -0,0 +1,7 @@ +1. 当数据偏小时,可能社区下没有网格,例如 网格发文数量得分就为0; +2. screen_index_data_monthly中的 数据条数 与客户下(组织数 + 直属部门数 + 网格数)的和不统一, + 原因:数据插入的时候,只算到了区县级,区县级以上的没有计算,少了 市级和省级agency + +文档地址: + 1. 大屏指标项文档说明:https://www.kdocs.cn/view/l/svtSfaUyzNYZ?f=130 + 2. 大屏或手机端:https://www.kdocs.cn/view/l/suilmk0Ziss1?f=130 \ No newline at end of file diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java index 2fc5ea1378..ca4d773f2a 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java @@ -1,7 +1,6 @@ package com.epmet.service.impl; -import com.alibaba.druid.util.StringUtils; -import com.epmet.commons.tools.constant.NumConstant; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; @@ -23,15 +22,8 @@ public class DimPartyMemberServiceImpl implements DimPartyMemberService { @Override - public Result getPartyInfo(String dateId) { - CustomerIdAndDateIdFormDTO c = new CustomerIdAndDateIdFormDTO(); - if (!StringUtils.isEmpty(dateId)) { - c.setDateId(dateId); - }else { - String now = LocalDate.now().minusDays(NumConstant.ONE).toString(); - String concat = now.substring(NumConstant.ZERO, NumConstant.FOUR).concat(now.substring(NumConstant.FIVE, NumConstant.SEVEN)).concat(now.substring(NumConstant.EIGHT, NumConstant.TEN)); - c.setDateId(concat); - } - return statsFeignClient.getPartyInfo(c); + public Result getPartyInfo(String form) { + CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO = JSON.parseObject(form, CustomerIdAndDateIdFormDTO.class); + return statsFeignClient.getPartyInfo(customerIdAndDateIdFormDTO); } }