forked from luyan/epmet-cloud-lingshan
14 changed files with 217 additions and 181 deletions
@ -0,0 +1,30 @@ |
|||||
|
package com.epmet.dto.stats.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 人房信息统计数,按天统计 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2022-05-27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class FactUserHouseFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 客户id |
||||
|
*/ |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 数据更新至:yyyyMMdd; |
||||
|
*/ |
||||
|
private String dateId; |
||||
|
|
||||
|
} |
@ -1,80 +1,32 @@ |
|||||
package com.epmet.service.org.impl; |
package com.epmet.service.org.impl; |
||||
|
|
||||
import com.epmet.commons.tools.constant.NumConstant; |
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
||||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
||||
import com.epmet.commons.tools.exception.EpmetException; |
|
||||
import com.epmet.commons.tools.feign.ResultDataResolver; |
import com.epmet.commons.tools.feign.ResultDataResolver; |
||||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
import com.epmet.constant.DataSourceConstant; |
||||
import com.epmet.dao.org.IcHouseDao; |
import com.epmet.dao.org.IcHouseDao; |
||||
import com.epmet.dto.form.HouseChartFormDTO; |
import com.epmet.dto.stats.form.FactUserHouseFormDTO; |
||||
import com.epmet.dto.result.HouseChartResultDTO; |
import com.epmet.dto.stats.result.FactUserHouseResultDTO; |
||||
import com.epmet.dto.result.HouseIcResiUserResultDTO; |
import com.epmet.entity.org.IcHouseEntity; |
||||
import com.epmet.service.org.HouseService; |
import com.epmet.service.org.HouseService; |
||||
import com.google.common.cache.Cache; |
|
||||
import com.google.common.cache.CacheBuilder; |
|
||||
import lombok.extern.slf4j.Slf4j; |
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang3.StringUtils; |
|
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
import java.text.NumberFormat; |
|
||||
import java.util.List; |
import java.util.List; |
||||
import java.util.concurrent.TimeUnit; |
|
||||
import java.util.concurrent.atomic.AtomicInteger; |
|
||||
|
|
||||
@Slf4j |
@Slf4j |
||||
|
@DataSource(DataSourceConstant.GOV_ORG) |
||||
@Service |
@Service |
||||
public class HouseServiceImpl implements HouseService, ResultDataResolver { |
public class HouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntity> implements HouseService, ResultDataResolver { |
||||
|
|
||||
/** |
@Override |
||||
* 导出房屋内家庭成员时本地缓存 |
public List<FactUserHouseResultDTO> houseStat(FactUserHouseFormDTO formDTO) { |
||||
*/ |
return baseDao.houseStat(formDTO); |
||||
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 |
@Override |
||||
public HouseChartResultDTO houseChart(HouseChartFormDTO formDTO) { |
public List<FactUserHouseResultDTO> neighborhoodStat(FactUserHouseFormDTO formDTO) { |
||||
HouseChartResultDTO resultDTO = new HouseChartResultDTO(); |
return baseDao.neighborhoodStatStat(formDTO); |
||||
//计算百分比使用,保留小数点后两位
|
|
||||
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; |
|
||||
} |
} |
||||
|
|
||||
} |
} |
||||
|
Loading…
Reference in new issue