diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyTypepercentResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyTypepercentResultDTO.java index 34bc09d38b..5a5112a4a8 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyTypepercentResultDTO.java +++ b/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; /** * 联建单位编码 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java index 81afd27ab7..cf4f96c510 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java +++ b/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 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 getTypepercent(PartyTypepercentFormDTO form) { - List 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> dictResult = epmetAdminOpenFeignClient.dictList(dictFromDTO); + if (!dictResult.success()) { + throw new EpmetException(dictResult.getCode()); } - return dto; + + List result = baseDao.getTypepercent(form.getAgencyId()); + Map 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 map, String matter) { diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml index 2938ee960e..30925f1867 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml @@ -112,9 +112,8 @@