From 904f9a92b43b920183ef37d494a7ff4ac31acb39 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 22 Apr 2022 10:18:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B0=86=E8=BA=AB=E4=BB=BD=E8=AF=81?= =?UTF-8?q?=E5=8F=B7=E7=9A=84=E6=89=93=E7=A0=81=E6=96=B9=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=AD=A3=E5=88=99=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/processor/MaskProcessor.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java index a6b13019a6..353fb06a47 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java @@ -152,7 +152,9 @@ public class MaskProcessor { return originString; } - return originString.replace(originString.substring(6), StrUtil.repeatByLength("*", length - 6)); + String maskStr = StrUtil.repeatByLength("*", length - 6); + + return originString.replaceAll("^(\\d{6})[a-zA-Z0-9]*$", new StringBuilder("$1").append(maskStr).toString()); } /** @@ -171,4 +173,11 @@ public class MaskProcessor { return originString.replaceAll("^(1\\d{2})\\d*(\\d{4})$", new StringBuilder("$1").append(maskStr).append("$2").toString()); } + + public static void main(String[] args) { + String[] idc = {"idCard"}; + String[] idct = {MaskResponse.MASK_TYPE_ID_CARD}; + String r = new MaskProcessor(idc, idct).maskString("333333333333333333", MaskResponse.MASK_TYPE_ID_CARD); + System.out.println(r); + } } From 7682f410aed62761fd7331ed472750946f249af7 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 22 Apr 2022 10:30:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BA=BA=E6=88=BF=E6=A6=82=E8=A7=88=5F?= =?UTF-8?q?=E6=88=BF=E5=B1=8B=E9=A5=BC=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/result/HouseChartResultDTO.java | 22 ++++++---- .../main/java/com/epmet/dao/IcHouseDao.java | 10 +++-- .../epmet/service/impl/HouseServiceImpl.java | 40 ++++++++++++++++++- .../src/main/resources/mapper/IcHouseDao.xml | 34 ++++++++++++++++ 4 files changed, 94 insertions(+), 12 deletions(-) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java index b412f00b07..676fe730f3 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseChartResultDTO.java @@ -1,5 +1,7 @@ package com.epmet.dto.result; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -21,30 +23,36 @@ public class HouseChartResultDTO implements Serializable { /** * 房屋总数 */ - private Integer houseTotal; + private Integer houseTotal = 0; /** * 房屋自住总数 */ - private Integer zzHouseTotal; + private Integer zzHouseTotal = 0; /** * 房屋自住总数占比(保留两位小数,带百分号的) */ - private String zzHouseRatio; + private String zzHouseRatio = "0%"; /** * 房屋常住总数 */ - private Integer czHouseTotal; + private Integer czHouseTotal = 0; /** * 房屋常住总数占比(保留两位小数,带百分号的) */ - private String czHouseRatio; + private String czHouseRatio = "0%"; /** * 房屋闲置总数 */ - private Integer xzHouseTotal; + private Integer xzHouseTotal = 0; /** * 房屋闲置总数占比(保留两位小数,带百分号的) */ - private String xzHouseRatio; + private String xzHouseRatio = "0%"; + + @JsonIgnore + private Integer num; + //1:出租 0:自住 2:闲置 + @JsonIgnore + private Integer rentFlag; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index 3b7428dd8b..50ecb715b2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -3,10 +3,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.IcHouseListFormDTO; -import com.epmet.dto.result.HouseInfoDTO; -import com.epmet.dto.result.HousesNameResultDTO; -import com.epmet.dto.result.IcHouseListResultDTO; -import com.epmet.dto.result.NeighborHoodManageDelResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.IcHouseEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -83,4 +80,9 @@ public interface IcHouseDao extends BaseDao { */ List getHousesNameByIdCards(@Param("idCards") List idCards); + /** + * @Author sun + * @Description 【人房】房屋总数饼图 + **/ + List houseChart(@Param("orgId") String orgId, @Param("orgType") String orgType); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 2d54a6d4c7..6072a5f15c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -6,6 +6,7 @@ import com.alibaba.excel.ExcelReader; import com.alibaba.excel.read.metadata.ReadSheet; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -13,6 +14,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; @@ -50,8 +52,10 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; +import java.text.NumberFormat; import java.util.*; import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @Slf4j @@ -348,7 +352,41 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { **/ @Override public HouseChartResultDTO houseChart(HouseChartFormDTO formDTO) { - return null; + HouseChartResultDTO resultDTO = new HouseChartResultDTO(); + //计算百分比使用,保留小数点后两位 + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(NumConstant.TWO); + //1.判断入参是否有值,没有值则赋值当前工作人员缓存中所属组织信息 + if (StringUtils.isEmpty(formDTO.getOrgId())) { + //2.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + formDTO.setOrgId(staffInfo.getAgencyId()); + formDTO.setOrgType("agency"); + } + //2.根据入参值查询对应的房屋统计数据 + List list = icHouseDao.houseChart(formDTO.getOrgId(), formDTO.getOrgType()); + //3.汇总数据 + AtomicInteger houseTotal = new AtomicInteger(); + list.forEach(l -> { + houseTotal.addAndGet(l.getNum()); + if (l.getRentFlag() == 0) { + resultDTO.setZzHouseTotal(l.getNum()); + } else if (l.getRentFlag() == 0) { + resultDTO.setCzHouseTotal(l.getNum()); + } else { + resultDTO.setXzHouseTotal(l.getNum()); + } + }); + resultDTO.setHouseTotal(houseTotal.get()); + resultDTO.setZzHouseRatio((resultDTO.getHouseTotal() == 0 || resultDTO.getZzHouseTotal() > resultDTO.getHouseTotal()) ? "0%" : numberFormat.format(((float) resultDTO.getZzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100) + "%"); + resultDTO.setCzHouseRatio((resultDTO.getHouseTotal() == 0 || resultDTO.getCzHouseTotal() > resultDTO.getHouseTotal()) ? "0%" : numberFormat.format(((float) resultDTO.getCzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100) + "%"); + resultDTO.setXzHouseRatio((resultDTO.getHouseTotal() == 0 || resultDTO.getXzHouseTotal() > resultDTO.getHouseTotal()) ? "0%" : numberFormat.format(((float) resultDTO.getXzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100) + "%"); + resultDTO.setOrgId(formDTO.getOrgId()); + resultDTO.setOrgType(formDTO.getOrgType()); + return resultDTO; } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 4712160069..818e89ba99 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -289,4 +289,38 @@ ) GROUP BY h.OWNER_ID_CARD + + +