小区汇总数据接口修改

This commit is contained in:
尹吉欢
2018-03-28 17:08:57 +08:00
parent 9b4daec568
commit a2e06e2ece
5 changed files with 473 additions and 113 deletions
@@ -5,6 +5,7 @@ import com.fangjia.job.common.core.JacksonEncoder;
import feign.Feign;
import feign.Logger;
import feign.Request.Options;
/**
* Rest API 调用工具类<br>
@@ -21,7 +22,7 @@ public class RestApiCallUtils {
* @return
*/
public static <T> T getRestClient(Class<T> apiType, String url) {
return Feign.builder().encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
return Feign.builder().encoder(new JacksonEncoder()).decoder(new JacksonDecoder()).options(new Options(10 * 1000, 100 * 1000))
.logLevel(Logger.Level.FULL)
.target(apiType, url);
}
@@ -1,7 +1,7 @@
package com.fangjia.job.youfang.document;
import java.util.Date;
import java.util.List;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@@ -11,6 +11,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
*/
@Document(collection="district_detail")
public class DistrictDetail {
@Id
private String id;
@@ -29,62 +30,175 @@ public class DistrictDetail {
*/
private String name;
/**
* 地址
*/
private String address;
/**
* 更新时间
*/
private Date modifyTime;
/**
* 中介信息
* 潜力指数
*/
private AgencyInfo agencyInfo;
/**
* 小区综合信息(标签等)
*/
private DistrictEvaluateDto districtNewPriceInfo;
/**
* 小区基础信息
*/
private DistrictBaseInfoDto districtBaseInfo;
private int index;
/**
* 小区潜力指数
* 最新均价
*/
private Integer index;
private int avgPrice;
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public DistrictBaseInfoDto getDistrictBaseInfo() {
return districtBaseInfo;
}
public void setDistrictBaseInfo(DistrictBaseInfoDto districtBaseInfo) {
this.districtBaseInfo = districtBaseInfo;
}
public DistrictEvaluateDto getDistrictNewPriceInfo() {
return districtNewPriceInfo;
}
public void setDistrictNewPriceInfo(DistrictEvaluateDto districtNewPriceInfo) {
this.districtNewPriceInfo = districtNewPriceInfo;
}
/**
* 涨跌幅在城市中的排名
*/
private double upDownRangecityLevel;
/**
* 上月参考均价
*/
private Integer topMonthAvgPrice;
/**
* 近1年涨跌幅(%)
*/
private Double oneYearUpDownRange;
/**
* 租房回报率
*/
private Double rentRate;
/**
* 近30天涨跌幅(%)
*/
private Double oneMonthUpDownRange;
/**
* 价格城市中的排名
*/
private double priceRate;
/**
* 流动性评级得分
*/
private double totalScore;
/**
* 一年前房屋均价
*/
private int oneYearAvgPrice;
/**
* 相对最高价
*/
private int cityDistrictMaxSellPrice;
/**
* 相对最低价
*/
private int cityDistrictMinSellPrice;
/**
* 小区标签
*/
private List<String> poiTags;
/**
* 小区标签数量(排序用)
*/
private int poiSize;
/**
* 百度经度
*/
private double lng2;
/**
* 百度纬度
*/
private double lat2;
/**
* 开发商
*/
private String developer;
/**
* 物业公司
*/
private String estateCompany;
/**
* 容积率
*/
private String cubagePercent;
/**
* 绿化率
*/
private String virescencePercent;
/**
* 物业费
*/
private String estateCharge;
/**
* 创建时间
*/
private String buildDate;
/**
* 停车位
*/
private Integer carSiteCount;
/**
* 总户数
*/
private Integer householdCount;
/**
* 竣工时间
*/
private String finishBuildingDate;
/**
* 主力面积
*/
private String moreArea;
/**
* 中介总数量
*/
private int agencyMount;
/**
* 知名中介数量
*/
private int famousAgency;
/**
* 其他中介数量
*/
private int otherAgency;
/**
* 中介数量在城市中的排名
*/
private int momCityLevel;
/**
* 城市排名总量
*/
private int citySize;
/**
* 城市中介最多的数量
*/
private int maxCityAgency;
public String getId() {
return id;
@@ -118,12 +232,276 @@ public class DistrictDetail {
this.name = name;
}
public AgencyInfo getAgencyInfo() {
return agencyInfo;
public String getAddress() {
return address;
}
public void setAgencyInfo(AgencyInfo agencyInfo) {
this.agencyInfo = agencyInfo;
public void setAddress(String address) {
this.address = address;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public int getAvgPrice() {
return avgPrice;
}
public void setAvgPrice(int avgPrice) {
this.avgPrice = avgPrice;
}
public double getUpDownRangecityLevel() {
return upDownRangecityLevel;
}
public void setUpDownRangecityLevel(double upDownRangecityLevel) {
this.upDownRangecityLevel = upDownRangecityLevel;
}
public Integer getTopMonthAvgPrice() {
return topMonthAvgPrice;
}
public void setTopMonthAvgPrice(Integer topMonthAvgPrice) {
this.topMonthAvgPrice = topMonthAvgPrice;
}
public Double getOneYearUpDownRange() {
return oneYearUpDownRange;
}
public void setOneYearUpDownRange(Double oneYearUpDownRange) {
this.oneYearUpDownRange = oneYearUpDownRange;
}
public Double getRentRate() {
return rentRate;
}
public void setRentRate(Double rentRate) {
this.rentRate = rentRate;
}
public Double getOneMonthUpDownRange() {
return oneMonthUpDownRange;
}
public void setOneMonthUpDownRange(Double oneMonthUpDownRange) {
this.oneMonthUpDownRange = oneMonthUpDownRange;
}
public double getPriceRate() {
return priceRate;
}
public void setPriceRate(double priceRate) {
this.priceRate = priceRate;
}
public double getTotalScore() {
return totalScore;
}
public void setTotalScore(double totalScore) {
this.totalScore = totalScore;
}
public int getOneYearAvgPrice() {
return oneYearAvgPrice;
}
public void setOneYearAvgPrice(int oneYearAvgPrice) {
this.oneYearAvgPrice = oneYearAvgPrice;
}
public int getCityDistrictMaxSellPrice() {
return cityDistrictMaxSellPrice;
}
public void setCityDistrictMaxSellPrice(int cityDistrictMaxSellPrice) {
this.cityDistrictMaxSellPrice = cityDistrictMaxSellPrice;
}
public int getCityDistrictMinSellPrice() {
return cityDistrictMinSellPrice;
}
public void setCityDistrictMinSellPrice(int cityDistrictMinSellPrice) {
this.cityDistrictMinSellPrice = cityDistrictMinSellPrice;
}
public List<String> getPoiTags() {
return poiTags;
}
public void setPoiTags(List<String> poiTags) {
this.poiTags = poiTags;
}
public int getPoiSize() {
return poiSize;
}
public void setPoiSize(int poiSize) {
this.poiSize = poiSize;
}
public double getLng2() {
return lng2;
}
public void setLng2(double lng2) {
this.lng2 = lng2;
}
public double getLat2() {
return lat2;
}
public void setLat2(double lat2) {
this.lat2 = lat2;
}
public String getDeveloper() {
return developer;
}
public void setDeveloper(String developer) {
this.developer = developer;
}
public String getEstateCompany() {
return estateCompany;
}
public void setEstateCompany(String estateCompany) {
this.estateCompany = estateCompany;
}
public String getCubagePercent() {
return cubagePercent;
}
public void setCubagePercent(String cubagePercent) {
this.cubagePercent = cubagePercent;
}
public String getVirescencePercent() {
return virescencePercent;
}
public void setVirescencePercent(String virescencePercent) {
this.virescencePercent = virescencePercent;
}
public String getEstateCharge() {
return estateCharge;
}
public void setEstateCharge(String estateCharge) {
this.estateCharge = estateCharge;
}
public String getBuildDate() {
return buildDate;
}
public void setBuildDate(String buildDate) {
this.buildDate = buildDate;
}
public Integer getCarSiteCount() {
return carSiteCount;
}
public void setCarSiteCount(Integer carSiteCount) {
this.carSiteCount = carSiteCount;
}
public Integer getHouseholdCount() {
return householdCount;
}
public void setHouseholdCount(Integer householdCount) {
this.householdCount = householdCount;
}
public String getFinishBuildingDate() {
return finishBuildingDate;
}
public void setFinishBuildingDate(String finishBuildingDate) {
this.finishBuildingDate = finishBuildingDate;
}
public String getMoreArea() {
return moreArea;
}
public void setMoreArea(String moreArea) {
this.moreArea = moreArea;
}
public int getAgencyMount() {
return agencyMount;
}
public void setAgencyMount(int agencyMount) {
this.agencyMount = agencyMount;
}
public int getFamousAgency() {
return famousAgency;
}
public void setFamousAgency(int famousAgency) {
this.famousAgency = famousAgency;
}
public int getOtherAgency() {
return otherAgency;
}
public void setOtherAgency(int otherAgency) {
this.otherAgency = otherAgency;
}
public int getMomCityLevel() {
return momCityLevel;
}
public void setMomCityLevel(int momCityLevel) {
this.momCityLevel = momCityLevel;
}
public int getCitySize() {
return citySize;
}
public void setCitySize(int citySize) {
this.citySize = citySize;
}
public int getMaxCityAgency() {
return maxCityAgency;
}
public void setMaxCityAgency(int maxCityAgency) {
this.maxCityAgency = maxCityAgency;
}
}
@@ -0,0 +1,22 @@
package com.fangjia.job.youfang.dto;
import com.fangjia.job.common.base.ReponseData;
import com.fangjia.job.youfang.document.DistrictDetail;
/**
* 小区数据汇总结果
* @author yinjihuan
*
*/
public class DistrictDetailDto extends ReponseData {
private DistrictDetail result;
public DistrictDetail getResult() {
return result;
}
public void setResult(DistrictDetail result) {
this.result = result;
}
}
@@ -9,6 +9,7 @@ import java.util.concurrent.Semaphore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@@ -19,16 +20,9 @@ import org.springframework.data.mongodb.core.query.Query;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.fangjia.job.common.util.DingDingMessageUtil;
import com.fangjia.job.common.util.JsonUtils;
import com.fangjia.job.common.util.RestApiCallUtils;
import com.fangjia.job.youfang.document.AgencyInfo;
import com.fangjia.job.youfang.document.DistrictBaseInfoDto;
import com.fangjia.job.youfang.document.DistrictDetail;
import com.fangjia.job.youfang.document.DistrictDto;
import com.fangjia.job.youfang.document.DistrictEvaluateDto;
import com.fangjia.job.youfang.document.DistrictEvaluateSingleDto;
import com.fangjia.job.youfang.document.DistrictInfoDto;
import com.fangjia.job.youfang.document.DistrictSearchSingleDto;
import com.fangjia.job.youfang.dto.DistrictDetailDto;
import com.fangjia.job.youfang.remote.FshApiRemoteService;
import com.mongodb.BasicDBObject;
import com.mongodb.Bytes;
@@ -79,69 +73,27 @@ public class DistrictInfoJob implements SimpleJob{
String name = String.valueOf(data.get("name"));
Map<String, Object> params = new HashMap<String,Object>();
params.put("city", city);
params.put("district", region);
params.put("region", region);
params.put("name", name);
params.put("token", token);
DistrictDetail districtDetail = mongoTemplate.findOne(Query.query(Criteria.where("city").is(city).and("region").is(region).and("name").is(name)), DistrictDetail.class);
String id = null;
if(districtDetail == null) {
districtDetail = new DistrictDetail();
} else {
id = districtDetail.getId();
}
DistrictDetailDto dto = fshApiRemoteService.districtDetail(params);
if (dto != null && dto.getResult() != null) {
BeanUtils.copyProperties(dto.getResult(), districtDetail);
}
if (id != null) {
districtDetail.setId(id);
}
districtDetail.setCity(city);
districtDetail.setRegion(region);
districtDetail.setName(name);
districtDetail.setModifyTime(new Date());
DistrictEvaluateSingleDto dto = fshApiRemoteService.getDistrictNewPriceInfo(params);
if (dto != null && dto.getResult() != null && dto.getResult().getTagBo() != null) {
districtDetail.setIndex(dto.getResult().getTagBo().getIndex());
}
DistrictInfoDto districtInfoDto = fshApiRemoteService.detail(params);
Map<String,Object> s = fshApiRemoteService.getAgencyInfo(params);
params.put("size", 111.11);
params.put("propertyType", 2);
DistrictSearchSingleDto dssDto = fshApiRemoteService.evaluate(params);
AgencyInfo a = new AgencyInfo();
if(s!=null&&(s.get("result")!=null)) {
Map<String,Object> result = (Map<String, Object>) s.get("result");
a.setAgencyMount(result.get("agencyMount")==null?0:(Integer)result.get("agencyMount"));
a.setCitySize(result.get("citySize")==null?0:(Integer)result.get("citySize"));
a.setFamousAgency(result.get("famousAgency")==null?0:(Integer)result.get("famousAgency"));
a.setMaxCityAgency(result.get("maxCityAgency")==null?0:(Integer)result.get("maxCityAgency"));
a.setMomCityLevel(result.get("momCityLevel")==null?0:(Integer)result.get("momCityLevel"));
a.setOtherAgency(result.get("otherAgency")==null?0:(Integer)result.get("otherAgency"));
}
DistrictEvaluateDto deDto = dto==null?null:dto.getResult();
if(deDto!=null&&null!=dssDto&&dssDto.getResult()!=null) {
DistrictDto dDto = dssDto.getResult();
deDto.setUpDownRangecityLevel(dDto.getUpDownRangecityLevel());
deDto.setAvgPrice(dDto.getAvgPrice());
deDto.setCityDistrictMaxSellPrice(dDto.getCityDistrictMaxSellPrice());
deDto.setCityDistrictMinSellPrice(dDto.getCityDistrictMinSellPrice());
deDto.setPriceRate(dDto.getPriceRate());
}
DistrictBaseInfoDto dbiDto = districtInfoDto==null?null:districtInfoDto.getResult();
if(dbiDto!=null&&null!=dssDto&&dssDto.getResult()!=null) {
DistrictDto add = dssDto.getResult();// FROM evaluate
DistrictDto original = dbiDto.getDistrict();
original.setUpDownRangecityLevel(add.getUpDownRangecityLevel());
original.setAvgPrice(add.getAvgPrice());
original.setCityDistrictMaxSellPrice(add.getCityDistrictMaxSellPrice());
original.setCityDistrictMinSellPrice(add.getCityDistrictMinSellPrice());
original.setPriceRate(add.getPriceRate());
original.setTotalScore(add.getTotalScore());
original.setLat2(add.getLat2());
original.setLng2(add.getLng2());
original.setTag(add.getTag());
int oneYearAvgPrice = add.getOneYearAvgPrice();
original.setOneYearAvgPrice(oneYearAvgPrice);
original.setLevelRate(add.getLevelRate());//
if(add.getOneMonthAvgPrice()!=0) {
original.setOneMonthAvgPrice(add.getOneMonthAvgPrice());
}
}
districtDetail.setAgencyInfo(a);
districtDetail.setDistrictBaseInfo(null!=districtInfoDto?districtInfoDto.getResult():null);
districtDetail.setDistrictNewPriceInfo(deDto);
mongoTemplate.save(districtDetail);
}catch(Exception e) {
logger.error("有房小区详情数据汇总异常", e);
@@ -6,6 +6,7 @@ import com.fangjia.job.common.base.Response;
import com.fangjia.job.youfang.document.DistrictEvaluateSingleDto;
import com.fangjia.job.youfang.document.DistrictInfoDto;
import com.fangjia.job.youfang.document.DistrictSearchSingleDto;
import com.fangjia.job.youfang.dto.DistrictDetailDto;
import feign.Param;
import feign.QueryMap;
@@ -69,4 +70,10 @@ public interface FshApiRemoteService {
*/
@RequestLine("GET /district/details")
public String refreshDistrictDetailPageData(@QueryMap Map<String, Object> queryMap);
/**
* 小区信息汇总
*/
@RequestLine("GET /fsh/districtDetail")
public DistrictDetailDto districtDetail(@QueryMap Map<String, Object> queryMap);
}