10 changed files with 1001 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||
package com.epmet.dao.org; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.HouseChartResultDTO; |
|||
import com.epmet.entity.org.IcHouseEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 房屋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
@Mapper |
|||
public interface IcHouseDao extends BaseDao<IcHouseEntity> { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【人房】房屋总数饼图 |
|||
**/ |
|||
List<HouseChartResultDTO> houseChart(@Param("orgId") String orgId, @Param("orgType") String orgType); |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dao.user; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.UserChartResultDTO; |
|||
import com.epmet.entity.user.IcResiUserEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 用户基础信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-26 |
|||
*/ |
|||
@Mapper |
|||
public interface IcResiUserDao extends BaseDao<IcResiUserEntity> { |
|||
|
|||
List<UserChartResultDTO> userChart(@Param("orgId") String orgId, @Param("orgType") String orgType); |
|||
|
|||
} |
@ -0,0 +1,110 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.entity.org; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 房屋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_house") |
|||
public class IcHouseEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 小区id |
|||
*/ |
|||
private String neighborHoodId; |
|||
|
|||
/** |
|||
* 片区id,neighbor_hood_part.id,可为空。 |
|||
*/ |
|||
private String partId; |
|||
|
|||
/** |
|||
* 所属楼栋id |
|||
*/ |
|||
private String buildingId; |
|||
|
|||
/** |
|||
* 所属单元id |
|||
*/ |
|||
private String buildingUnitId; |
|||
|
|||
/** |
|||
* 房屋名字后台插入时生成 |
|||
*/ |
|||
private String houseName; |
|||
|
|||
/** |
|||
* 门牌号 |
|||
*/ |
|||
private String doorName; |
|||
|
|||
/** |
|||
* 房屋类型,这里存储字典value就可以 |
|||
*/ |
|||
private String houseType; |
|||
|
|||
/** |
|||
* 存储字典value |
|||
*/ |
|||
private String purpose; |
|||
|
|||
/** |
|||
* 1出租;0未出租 |
|||
*/ |
|||
private Integer rentFlag; |
|||
|
|||
/** |
|||
* 房主姓名 |
|||
*/ |
|||
private String ownerName; |
|||
|
|||
/** |
|||
* 房主电话 |
|||
*/ |
|||
private String ownerPhone; |
|||
|
|||
/** |
|||
* 房主身份证号 |
|||
*/ |
|||
private String ownerIdCard; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private BigDecimal sort; |
|||
|
|||
} |
@ -0,0 +1,513 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.entity.user; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 用户基础信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-26 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_resi_user") |
|||
public class IcResiUserEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id customer.id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 所属小区ID |
|||
*/ |
|||
private String villageId; |
|||
|
|||
/** |
|||
* 所属楼宇Id |
|||
*/ |
|||
private String buildId; |
|||
|
|||
/** |
|||
* 单元id |
|||
*/ |
|||
private String unitId; |
|||
|
|||
/** |
|||
* 所属家庭Id |
|||
*/ |
|||
private String homeId; |
|||
|
|||
/** |
|||
* 是否本地户籍 |
|||
*/ |
|||
private String isBdhj; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 性别 |
|||
*/ |
|||
private String gender; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 出生日期 |
|||
*/ |
|||
private String birthday; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remarks; |
|||
|
|||
/** |
|||
* 联系人 |
|||
*/ |
|||
private String contacts; |
|||
|
|||
/** |
|||
* 联系人电话 |
|||
*/ |
|||
private String contactsMobile; |
|||
|
|||
/** |
|||
* 九小场所url |
|||
*/ |
|||
private String ninePlace; |
|||
|
|||
/** |
|||
* 是否党员 |
|||
*/ |
|||
private String isParty; |
|||
|
|||
/** |
|||
* 是否低保户 |
|||
*/ |
|||
private String isDbh; |
|||
|
|||
/** |
|||
* 是否保障房 |
|||
*/ |
|||
private String isEnsureHouse; |
|||
|
|||
/** |
|||
* 是否失业 |
|||
*/ |
|||
private String isUnemployed; |
|||
|
|||
/** |
|||
* 是否育龄妇女 |
|||
*/ |
|||
private String isYlfn; |
|||
|
|||
/** |
|||
* 是否退役军人 |
|||
*/ |
|||
private String isVeterans; |
|||
|
|||
/** |
|||
* 是否统战人员 |
|||
*/ |
|||
private String isUnitedFront; |
|||
|
|||
/** |
|||
* 是否信访人员 |
|||
*/ |
|||
private String isXfry; |
|||
|
|||
/** |
|||
* 是否志愿者 |
|||
*/ |
|||
private String isVolunteer; |
|||
|
|||
/** |
|||
* 是否老年人 |
|||
*/ |
|||
private String isOldPeople; |
|||
|
|||
/** |
|||
* 是否空巢 |
|||
*/ |
|||
private String isKc; |
|||
|
|||
/** |
|||
* 是否失独 |
|||
*/ |
|||
private String isSd; |
|||
|
|||
/** |
|||
* 是否失能 |
|||
*/ |
|||
private String isSn; |
|||
|
|||
/** |
|||
* 是否失智 |
|||
*/ |
|||
private String isSz; |
|||
|
|||
/** |
|||
* 是否残疾 |
|||
*/ |
|||
private String isCj; |
|||
|
|||
/** |
|||
* 是否大病 |
|||
*/ |
|||
private String isDb; |
|||
|
|||
/** |
|||
* 是否慢病 |
|||
*/ |
|||
private String isMb; |
|||
|
|||
/** |
|||
* 是否特殊人群 |
|||
*/ |
|||
private String isSpecial; |
|||
|
|||
/** |
|||
* 是否租户【是:1 否:0】 |
|||
*/ |
|||
private String isTenant; |
|||
|
|||
/** |
|||
* 是否流动人口【是:1 否:0】 |
|||
*/ |
|||
private String isFloating; |
|||
|
|||
/** |
|||
* 文化程度【字典表】 |
|||
*/ |
|||
private String culture; |
|||
|
|||
/** |
|||
* 文化程度备注 |
|||
*/ |
|||
private String cultureRemakes; |
|||
|
|||
/** |
|||
* 特长【字典表】 |
|||
*/ |
|||
private String specialSkill; |
|||
|
|||
/** |
|||
* 兴趣爱好 |
|||
*/ |
|||
private String hobby; |
|||
|
|||
/** |
|||
* 兴趣爱好备注 |
|||
*/ |
|||
private String hobbyRemakes; |
|||
|
|||
/** |
|||
* 宗教信仰 |
|||
*/ |
|||
private String faith; |
|||
|
|||
/** |
|||
* 宗教信仰备注 |
|||
*/ |
|||
private String faithRemakes; |
|||
|
|||
/** |
|||
* 残疾类别【字典表】 |
|||
*/ |
|||
private String cjlb; |
|||
|
|||
/** |
|||
* 残疾登记(状况)【字典表】 |
|||
*/ |
|||
private String cjzk; |
|||
|
|||
/** |
|||
* 残疾证号 |
|||
*/ |
|||
private String cjzh; |
|||
|
|||
/** |
|||
* 残疾说明 |
|||
*/ |
|||
private String cjsm; |
|||
|
|||
/** |
|||
* 有无监护人【yes no】 |
|||
*/ |
|||
private String ynJdr; |
|||
|
|||
/** |
|||
* 有无技能特长【yes no】 |
|||
*/ |
|||
private String ynJntc; |
|||
|
|||
/** |
|||
* 有无劳动能力 |
|||
*/ |
|||
private String ynLdnl; |
|||
|
|||
/** |
|||
* 有无非义务教育阶段助学【yes no】 |
|||
*/ |
|||
private String ynFywjyjdzx; |
|||
|
|||
/** |
|||
* 所患大病 |
|||
*/ |
|||
private String shdb; |
|||
|
|||
/** |
|||
* 患大病时间 |
|||
*/ |
|||
private String dbsj; |
|||
|
|||
/** |
|||
* 所患慢性病 |
|||
*/ |
|||
private String shmxb; |
|||
|
|||
/** |
|||
* 患慢性病时间 |
|||
*/ |
|||
private String mxbsj; |
|||
|
|||
/** |
|||
* 是否参保 |
|||
*/ |
|||
private String isCb; |
|||
|
|||
/** |
|||
* 自付金额 |
|||
*/ |
|||
private String zfje; |
|||
|
|||
/** |
|||
* 救助金额 |
|||
*/ |
|||
private String jzje; |
|||
|
|||
/** |
|||
* 救助时间[yyyy-MM-dd] |
|||
*/ |
|||
private String jzsj; |
|||
|
|||
/** |
|||
* 享受救助明细序号 |
|||
*/ |
|||
private String jzmxxh; |
|||
|
|||
/** |
|||
* 健康信息备注 |
|||
*/ |
|||
private String healthRemakes; |
|||
|
|||
/** |
|||
* 工作单位 |
|||
*/ |
|||
private String gzdw; |
|||
|
|||
/** |
|||
* 职业 |
|||
*/ |
|||
private String zy; |
|||
|
|||
/** |
|||
* 离退休时间 |
|||
*/ |
|||
private String ltxsj; |
|||
|
|||
/** |
|||
* 工作信息备注 |
|||
*/ |
|||
private String workRemake; |
|||
|
|||
/** |
|||
* 退休金额 |
|||
*/ |
|||
private String txje; |
|||
|
|||
/** |
|||
* 月收入 |
|||
*/ |
|||
private String ysr; |
|||
|
|||
/** |
|||
* 籍贯 |
|||
*/ |
|||
private String jg; |
|||
|
|||
/** |
|||
* 户籍所在地 |
|||
*/ |
|||
private String hjszd; |
|||
|
|||
/** |
|||
* 现居住地 |
|||
*/ |
|||
private String xjzd; |
|||
|
|||
/** |
|||
* 人户情况 |
|||
*/ |
|||
private String rhzk; |
|||
|
|||
/** |
|||
* 居住信息备注 |
|||
*/ |
|||
private String jzxxRemakes; |
|||
|
|||
/** |
|||
* 民族【字典表】 |
|||
*/ |
|||
private String mz; |
|||
|
|||
/** |
|||
* 与户主关系【字典表】 |
|||
*/ |
|||
private String yhzgx; |
|||
|
|||
/** |
|||
* 居住情况【字典表】 |
|||
*/ |
|||
private String jzqk; |
|||
|
|||
/** |
|||
* 婚姻状况【字典表】 |
|||
*/ |
|||
private String hyzk; |
|||
|
|||
/** |
|||
* 配偶情况【字典表】 |
|||
*/ |
|||
private String poqk; |
|||
|
|||
/** |
|||
* 有无赡养人 |
|||
*/ |
|||
private String ynSyr; |
|||
|
|||
/** |
|||
* 与赡养人关系【字典表】 |
|||
*/ |
|||
private String ysyrgx; |
|||
|
|||
/** |
|||
* 赡养人电话 |
|||
*/ |
|||
private String syrMobile; |
|||
|
|||
/** |
|||
* 家庭信息备注 |
|||
*/ |
|||
private String jtxxRemakes; |
|||
|
|||
/** |
|||
* 用户状态【0:正常;1:迁出;2:注销】 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 用户详细状态:01:新增、02:导入、03:迁入、04:新生、11:迁出、21死亡 |
|||
*/ |
|||
private String subStatus; |
|||
|
|||
/** |
|||
* 预留字段1 |
|||
*/ |
|||
private String field1; |
|||
|
|||
/** |
|||
* 预留字段2 |
|||
*/ |
|||
private String field2; |
|||
|
|||
/** |
|||
* 预留字段3 |
|||
*/ |
|||
private String field3; |
|||
|
|||
/** |
|||
* 预留字段4 |
|||
*/ |
|||
private String field4; |
|||
|
|||
/** |
|||
* 预留字段5 |
|||
*/ |
|||
private String field5; |
|||
|
|||
/** |
|||
* 预留字段6 |
|||
*/ |
|||
private String field6; |
|||
|
|||
/** |
|||
* 预留字段7 |
|||
*/ |
|||
private String field7; |
|||
|
|||
/** |
|||
* 预留字段8 |
|||
*/ |
|||
private String field8; |
|||
|
|||
/** |
|||
* 预留字段9 |
|||
*/ |
|||
private String field9; |
|||
|
|||
/** |
|||
* 预留字段10 |
|||
*/ |
|||
private String field10; |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service.org; |
|||
|
|||
import com.epmet.dto.form.HouseChartFormDTO; |
|||
import com.epmet.dto.result.HouseChartResultDTO; |
|||
|
|||
/** |
|||
* 小区表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
public interface HouseService { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【人房】房屋总数饼图 |
|||
**/ |
|||
HouseChartResultDTO houseChart(HouseChartFormDTO formDTO); |
|||
|
|||
} |
@ -0,0 +1,80 @@ |
|||
package com.epmet.service.org.impl; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.dao.org.IcHouseDao; |
|||
import com.epmet.dto.form.HouseChartFormDTO; |
|||
import com.epmet.dto.result.HouseChartResultDTO; |
|||
import com.epmet.dto.result.HouseIcResiUserResultDTO; |
|||
import com.epmet.service.org.HouseService; |
|||
import com.google.common.cache.Cache; |
|||
import com.google.common.cache.CacheBuilder; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.text.NumberFormat; |
|||
import java.util.List; |
|||
import java.util.concurrent.TimeUnit; |
|||
import java.util.concurrent.atomic.AtomicInteger; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|||
|
|||
/** |
|||
* 导出房屋内家庭成员时本地缓存 |
|||
*/ |
|||
private static final Cache<String,List<HouseIcResiUserResultDTO.HouseMemberResultDTO>> memberCacheMap = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).expireAfterWrite(30,TimeUnit.MINUTES).build(); |
|||
|
|||
@Resource |
|||
private IcHouseDao icHouseDao; |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【人房】房屋总数饼图 |
|||
**/ |
|||
@Override |
|||
public HouseChartResultDTO houseChart(HouseChartFormDTO formDTO) { |
|||
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<HouseChartResultDTO> 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() == 1) { |
|||
resultDTO.setCzHouseTotal(l.getNum()); |
|||
} else { |
|||
resultDTO.setXzHouseTotal(l.getNum()); |
|||
} |
|||
}); |
|||
resultDTO.setHouseTotal(houseTotal.get()); |
|||
resultDTO.setZzHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getZzHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getZzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); |
|||
resultDTO.setCzHouseRatio(Double.valueOf((resultDTO.getHouseTotal() == 0 || resultDTO.getCzHouseTotal() > resultDTO.getHouseTotal()) ? "0" : numberFormat.format(((float) resultDTO.getCzHouseTotal() / (float) resultDTO.getHouseTotal()) * 100))); |
|||
resultDTO.setXzHouseRatio(Double.valueOf((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; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service.user; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.dto.form.UserChartFormDTO; |
|||
import com.epmet.dto.result.UserChartResultDTO; |
|||
import com.epmet.entity.user.IcResiUserEntity; |
|||
|
|||
/** |
|||
* 用户基础信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-26 |
|||
*/ |
|||
public interface IcResiUserService extends BaseService<IcResiUserEntity> { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【人房】居民总数饼图 |
|||
**/ |
|||
UserChartResultDTO userChart(UserChartFormDTO formDTO); |
|||
|
|||
} |
@ -0,0 +1,90 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service.user.impl; |
|||
|
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.dao.user.IcResiUserDao; |
|||
import com.epmet.dto.form.UserChartFormDTO; |
|||
import com.epmet.dto.result.UserChartResultDTO; |
|||
import com.epmet.entity.user.IcResiUserEntity; |
|||
import com.epmet.service.user.IcResiUserService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.text.NumberFormat; |
|||
import java.util.List; |
|||
import java.util.concurrent.atomic.AtomicInteger; |
|||
|
|||
/** |
|||
* 用户基础信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-26 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResiUserEntity> implements IcResiUserService, ResultDataResolver { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【人房】居民总数饼图 |
|||
**/ |
|||
@Override |
|||
public UserChartResultDTO userChart(UserChartFormDTO formDTO) { |
|||
UserChartResultDTO resultDTO = new UserChartResultDTO(); |
|||
//计算百分比使用,保留小数点后两位
|
|||
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<UserChartResultDTO> list = baseDao.userChart(formDTO.getOrgId(), formDTO.getOrgType()); |
|||
//3.汇总数据
|
|||
AtomicInteger userTotal = new AtomicInteger(); |
|||
list.forEach(l -> { |
|||
userTotal.addAndGet(l.getNum()); |
|||
if ("0".equals(l.getIsFloating())) { |
|||
resultDTO.setCzUserTotal(l.getNum()); |
|||
} else { |
|||
resultDTO.setLdUserTotal(l.getNum()); |
|||
} |
|||
}); |
|||
resultDTO.setUserTotal(userTotal.get()); |
|||
resultDTO.setCzUserRatio(Double.valueOf((resultDTO.getUserTotal() == 0 || resultDTO.getCzUserTotal() > resultDTO.getUserTotal()) ? "0" : numberFormat.format(((float) resultDTO.getCzUserTotal() / (float) resultDTO.getUserTotal()) * 100))); |
|||
resultDTO.setLdUserRatio(Double.valueOf((resultDTO.getUserTotal() == 0 || resultDTO.getLdUserTotal() > resultDTO.getUserTotal()) ? "0" : numberFormat.format(((float) resultDTO.getLdUserTotal() / (float) resultDTO.getUserTotal()) * 100))); |
|||
resultDTO.setOrgId(formDTO.getOrgId()); |
|||
resultDTO.setOrgType(formDTO.getOrgType()); |
|||
|
|||
return resultDTO; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.org.IcHouseDao"> |
|||
|
|||
<select id="houseChart" resultType="com.epmet.dto.result.HouseChartResultDTO"> |
|||
SELECT |
|||
COUNT(id) num, |
|||
rent_flag rentFlag |
|||
FROM |
|||
ic_house |
|||
WHERE del_flag = '0' |
|||
<choose> |
|||
<when test='orgType == "agency"'> |
|||
AND neighbor_hood_id IN ( |
|||
select id from ic_neighbor_hood |
|||
where del_flag = '0' |
|||
and (agency_id = #{orgId} OR agency_pids LIKE CONCAT('%', #{orgId}, '%')) |
|||
) |
|||
</when> |
|||
<when test='orgType == "grid"'> |
|||
AND neighbor_hood_id IN ( |
|||
select id from ic_neighbor_hood |
|||
where del_flag = '0' |
|||
and grid_id = #{orgId} |
|||
) |
|||
</when> |
|||
<otherwise> |
|||
AND neighbor_hood_id IN ( |
|||
select id from ic_neighbor_hood |
|||
where del_flag = '0' |
|||
and id = #{orgId} |
|||
) |
|||
</otherwise> |
|||
</choose> |
|||
GROUP BY rent_flag |
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,28 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.user.IcResiUserDao"> |
|||
|
|||
<select id="userChart" resultType="com.epmet.dto.result.UserChartResultDTO"> |
|||
SELECT |
|||
COUNT(id) num, |
|||
is_floating isFloating |
|||
FROM |
|||
ic_resi_user |
|||
WHERE |
|||
del_flag = '0' |
|||
<choose> |
|||
<when test='orgType == "agency"'> |
|||
AND (agency_id = #{orgId} OR pids LIKE CONCAT('%', #{orgId}, '%')) |
|||
</when> |
|||
<when test='orgType == "grid"'> |
|||
AND grid_id = #{orgId} |
|||
</when> |
|||
<otherwise> |
|||
AND village_id = #{orgId} |
|||
</otherwise> |
|||
</choose> |
|||
GROUP BY is_floating |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue