|
|
@ -67,22 +67,17 @@ import com.google.common.cache.CacheBuilder; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.http.HttpEntity; |
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
|
import org.apache.http.client.methods.HttpPost; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.sql.Date; |
|
|
|
import java.sql.Timestamp; |
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
@ -1606,8 +1601,40 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
* @Description 【人房】居民总数饼图 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public HouseChartResultDTO userChart(UserChartFormDTO formDTO) { |
|
|
|
return null; |
|
|
|
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((resultDTO.getUserTotal() == 0 || resultDTO.getCzUserTotal() > resultDTO.getUserTotal()) ? "0%" : numberFormat.format(((float) resultDTO.getCzUserTotal() / (float) resultDTO.getUserTotal()) * 100) + "%"); |
|
|
|
resultDTO.setLdUserRatio((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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|