Browse Source

联建单位-按分类统计数量及占比修改逻辑

dev
HAHA 3 years ago
parent
commit
08d7abc754
  1. 2
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyTypepercentResultDTO.java
  2. 31
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java
  3. 5
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml

2
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyTypepercentResultDTO.java

@ -19,7 +19,7 @@ public class PartyTypepercentResultDTO {
/**
* 数量
*/
private String value;
private Integer value;
/**
* 联建单位编码

31
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

@ -603,7 +603,7 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
PageHelper.startPage(form.getPageNo(), form.getPageSize());
List<PartyUnitListbrieResultDTO> dto = baseDao.getListbrief(form, tokenDto.getCustomerId());
// 获取gridName
for (PartyUnitListbrieResultDTO item:dto) {
for (PartyUnitListbrieResultDTO item : dto) {
if (StringUtils.isNotEmpty(item.getGridId())) {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(item.getGridId());
if (null != gridInfo) {
@ -617,15 +617,28 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
@Override
public List<PartyTypepercentResultDTO> getTypepercent(PartyTypepercentFormDTO form) {
List<PartyTypepercentResultDTO> dto = baseDao.getTypepercent(form.getAgencyId());
int total = 0;
for (PartyTypepercentResultDTO item : dto) {
total = Integer.parseInt(item.getValue()) + total;
}
for (PartyTypepercentResultDTO item : dto) {
item.setPercent((Integer.parseInt(item.getValue()) * 100) / total + "%");
DictListFormDTO dictFromDTO = new DictListFormDTO();
dictFromDTO.setDictType(DictTypeEnum.PARTY_UNIT_TYPE.getCode());
Result<List<DictListResultDTO>> dictResult = epmetAdminOpenFeignClient.dictList(dictFromDTO);
if (!dictResult.success()) {
throw new EpmetException(dictResult.getCode());
}
return dto;
List<PartyTypepercentResultDTO> result = baseDao.getTypepercent(form.getAgencyId());
Map<String, Integer> map = result.stream().collect(Collectors.toMap(PartyTypepercentResultDTO::getCode, PartyTypepercentResultDTO::getValue));
int sum = result.stream().mapToInt(PartyTypepercentResultDTO::getValue).sum();
return dictResult.getData().stream().map(item -> {
PartyTypepercentResultDTO dto = new PartyTypepercentResultDTO();
dto.setLabel(item.getLabel());
dto.setCode(item.getValue());
dto.setValue(null == map.get(item.getValue()) ? NumConstant.ZERO : map.get(item.getValue()));
dto.setPercent((Integer.parseInt(item.getValue()) * 100) / sum + "%");
return dto;
}).collect(Collectors.toList());
}
private String getServiceMatter(Map<String, String> map, String matter) {

5
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml

@ -112,9 +112,8 @@
</select>
<select id="getTypepercent" resultType="com.epmet.dto.result.PartyTypepercentResultDTO">
SELECT
a.type AS label,
count( a.type ) AS value,
a.id AS CODE
count( a.id ) AS value,
a.type AS CODE
FROM
ic_party_unit a
WHERE

Loading…
Cancel
Save