From 08d7abc754d37c34dce015c3735a65cde0082a90 Mon Sep 17 00:00:00 2001 From: HAHA Date: Thu, 19 May 2022 10:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E5=BB=BA=E5=8D=95=E4=BD=8D-=E6=8C=89?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=BB=9F=E8=AE=A1=E6=95=B0=E9=87=8F=E5=8F=8A?= =?UTF-8?q?=E5=8D=A0=E6=AF=94=E4=BF=AE=E6=94=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/PartyTypepercentResultDTO.java | 2 +- .../service/impl/IcPartyUnitServiceImpl.java | 31 +++++++++++++------ .../main/resources/mapper/IcPartyUnitDao.xml | 5 ++- 3 files changed, 25 insertions(+), 13 deletions(-) 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 @@