Browse Source

Merge remote-tracking branch 'origin/dev_screen_data_2.0' into dev_temp

master
zxc 5 years ago
parent
commit
b208da1106
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
  2. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java
  3. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
  4. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  5. 63
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  8. 7
      epmet-module/data-statistical/data-statistical-server/src/test/java/resources/数据值略小时可能的情况.txt
  9. 16
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java

1
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;

5
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;
}

1
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));
}

7
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()) {

63
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<DimCustom
*/
@Override
public Boolean statsPartyMember(CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) {
List<String> allCustomerId = dimCustomerService.getAllCustomerId();
if (CollectionUtils.isEmpty(allCustomerId)){
String customerIdOne = customerIdAndDateIdFormDTO.getCustomerId();
List<String> customerIds = new ArrayList<>();
List<String> 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<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId);
if (CollectionUtils.isEmpty(partyMemberList)){
log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId));
return;
}
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList());
List<GridBelongAgencyResultDTO> 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<String> finalDateIds = dateIds;
customerIds.forEach(customerId -> {
finalDateIds.forEach(dateId -> {
List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId);
if (CollectionUtils.isEmpty(partyMemberList)){
log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId));
return;
}
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList());
List<GridBelongAgencyResultDTO> 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;
}

2
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 {

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

7
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

16
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);
}
}

Loading…
Cancel
Save