Browse Source

社区党建数据分析-党员相关

master
zhaoqifeng 4 years ago
parent
commit
7112bd44c6
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OptionDataResultDTO.java
  2. 24
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OptionDataResultDTO.java

@ -15,4 +15,5 @@ public class OptionDataResultDTO implements Serializable {
private String label;
private String value;
private String code;
private String radio;
}

24
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -70,6 +70,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.*;
@ -972,17 +974,28 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
dictFormDTO.setDictType(DictTypeEnum.AGE_GROUP.getCode());
Result<List<DictListResultDTO>> dictResult = epmetAdminOpenFeignClient.dictList(dictFormDTO);
Map<String, String> map = new HashMap<>();
int total = 0;
//统计组织下各年龄范围人数
List<OptionDataResultDTO> list = baseDao.getPartyMemberAgeStatistics(formDTO.getOrgType(), formDTO.getOrgId());
if (CollectionUtils.isNotEmpty(list)) {
map = list.stream().collect(Collectors.toMap(OptionDataResultDTO::getCode, OptionDataResultDTO::getValue));
total = list.stream().mapToInt(item -> Integer.parseInt(item.getValue())).sum();
}
Map<String, String> finalMap = map;
int finalTotal = total;
return dictResult.getData().stream().map(item -> {
OptionDataResultDTO dto = new OptionDataResultDTO();
dto.setCode(item.getValue());
dto.setLabel(item.getLabel());
dto.setValue(null == finalMap.get(item.getValue())?NumConstant.ZERO_STR:finalMap.get(item.getValue()));
BigDecimal radio = new BigDecimal("0.00");
if (NumConstant.ZERO != finalTotal) {
BigDecimal sum = new BigDecimal(finalTotal);
BigDecimal count = new BigDecimal(dto.getValue());
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED);
radio = count.multiply(hundred).divide(sum, NumConstant.TWO, RoundingMode.HALF_UP);
}
dto.setRadio(radio.stripTrailingZeros().toString().concat("%"));
return dto;
}).collect(Collectors.toList());
}
@ -1022,15 +1035,26 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
Map<String, String> map = new HashMap<>();
//统计组织下文化程度党员人数
List<OptionDataResultDTO> list = baseDao.getPartyMemberEducationStatistics(formDTO.getOrgType(), formDTO.getOrgId());
int total = 0;
if (CollectionUtils.isNotEmpty(list)) {
map = list.stream().collect(Collectors.toMap(OptionDataResultDTO::getCode, OptionDataResultDTO::getValue));
total = list.stream().mapToInt(item -> Integer.parseInt(item.getValue())).sum();
}
Map<String, String> finalMap = map;
int finalTotal = total;
return dictResult.getData().stream().map(item -> {
OptionDataResultDTO dto = new OptionDataResultDTO();
dto.setCode(item.getValue());
dto.setLabel(item.getLabel());
dto.setValue(null == finalMap.get(item.getValue())?NumConstant.ZERO_STR:finalMap.get(item.getValue()));
BigDecimal radio = new BigDecimal("0.00");
if (NumConstant.ZERO != finalTotal) {
BigDecimal sum = new BigDecimal(finalTotal);
BigDecimal count = new BigDecimal(dto.getValue());
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED);
radio = count.multiply(hundred).divide(sum, NumConstant.TWO, RoundingMode.HALF_UP);
}
dto.setRadio(radio.stripTrailingZeros().toString().concat("%"));
return dto;
}).collect(Collectors.toList());
}

Loading…
Cancel
Save