拆开城市区域stat
This commit is contained in:
+36
-14
@@ -14,8 +14,11 @@ import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.fangjia.core.City;
|
||||
import com.fangjia.coresite.model.*;
|
||||
import com.fangjia.dal.mongo.model.*;
|
||||
import com.fangjia.service.bo.*;
|
||||
import com.fangjia.service.datastore.*;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@@ -39,21 +42,9 @@ import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.common.FangjiaServerAreaContextHolder;
|
||||
import com.fangjia.dal.datastore.model.News;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.CityTradeStat;
|
||||
import com.fangjia.dal.mongo.model.DistrictNewPrice;
|
||||
import com.fangjia.dal.mongo.model.DistrictSellStat;
|
||||
import com.fangjia.dal.mongo.model.DistrictStat;
|
||||
import com.fangjia.dal.mongo.model.DistrictTradeStat;
|
||||
import com.fangjia.dal.mongo.model.RegionBlock;
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.service.datastore.DistrictSellStatService;
|
||||
import com.fangjia.service.datastore.DistrictService;
|
||||
import com.fangjia.service.datastore.HouseService;
|
||||
import com.fangjia.service.datastore.RegionStatService;
|
||||
import com.fangjia.service.datastore.bean.HousePicEnum;
|
||||
import com.fangjia.service.datastore.bean.HouseQueryBean;
|
||||
import com.fangjia.service.datastore.EvaluationService;
|
||||
import com.fangjia.service.district.DistrictStatService;
|
||||
import com.fangjia.service.district.TradeStatService;
|
||||
import com.fangjia.service.fsh.DistrictNewPriceService;
|
||||
@@ -82,6 +73,8 @@ public class TrendController {
|
||||
private static int QUARTER_WEEK = 13;
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TrendController.class);
|
||||
|
||||
private CitySellStatService citySellStatService;
|
||||
|
||||
public Object trendChartAction(TrendModel model, HttpServletRequest request) {
|
||||
TrendView trendView = TrendViewFactory.getInstance().create(model);
|
||||
if (trendView != null) {
|
||||
@@ -189,8 +182,8 @@ public class TrendController {
|
||||
model.setRegion(trendView.getRegion());
|
||||
} else if (trendView.getType().equals(ViewType.city)) {
|
||||
//RegionStatBo regionStat = getRegionBlockStat(trendView.getCityName(), null, null);
|
||||
RegionStatBo regionStat = getNearestRegionStat(trendView.getCityName(), null, null);
|
||||
model.setRegionStatBo(regionStat);
|
||||
CitySellStatBo citySellStat = getNearestCitySellStat(trendView.getCityName());
|
||||
model.setCitySellStatBo(citySellStat);
|
||||
}
|
||||
|
||||
|
||||
@@ -826,6 +819,32 @@ public class TrendController {
|
||||
seriesOptions.addAll(data);
|
||||
}
|
||||
}
|
||||
private CitySellStatBo getNearestCitySellStat(String city) {
|
||||
CitySellStatBo ret = null;
|
||||
List<CitySellStat> citySellStats = null;
|
||||
Integer startDate = Integer.valueOf(DateUtil.formatToTightYYYYMMDD(DateUtils.addMonths(new Date(), -3)));
|
||||
citySellStats = citySellStatService.findNearCityStat(city, startDate, 2);
|
||||
if(citySellStats!=null && citySellStats.size()>0){
|
||||
CitySellStatBo bo = new CitySellStatBo();
|
||||
if(citySellStats.size()==2){
|
||||
bo.setAvgPrice(citySellStats.get(0).getAvgPrice());
|
||||
bo.setLastTimeAvgPrice(citySellStats.get(1).getAvgPrice());
|
||||
int monthMarkup = (citySellStats.get(0).getAvgPrice()-citySellStats.get(1).getAvgPrice())*10000/citySellStats.get(1).getAvgPrice();
|
||||
bo.setMonthMarkup(monthMarkup);
|
||||
|
||||
}else{
|
||||
bo.setAvgPrice(citySellStats.get(0).getAvgPrice());
|
||||
}
|
||||
|
||||
CitySellStat rs = citySellStatService.findStartStat(city);
|
||||
if(rs!=null){
|
||||
bo.setStartDate(rs.getDate());
|
||||
}
|
||||
return bo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private RegionStatBo getNearestRegionStat(String city, String region, String block){
|
||||
RegionStatBo ret = null;
|
||||
@@ -1284,4 +1303,7 @@ public class TrendController {
|
||||
this.evaluationService = evaluationService;
|
||||
}
|
||||
|
||||
public void setCitySellStatService(CitySellStatService citySellStatService) {
|
||||
this.citySellStatService = citySellStatService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class TrendModel extends BaseModel implements TrendViewModel {
|
||||
private String trendDesc;
|
||||
private DistrictStatBo districtStatBo;
|
||||
private RegionStatBo regionStatBo;
|
||||
private CitySellStatBo citySellStatBo;
|
||||
private String affectKeyword;
|
||||
private int chartWidth;
|
||||
private int chartHeight;
|
||||
@@ -330,4 +331,12 @@ public class TrendModel extends BaseModel implements TrendViewModel {
|
||||
public void setCityStatInfoBos(List<CityStatInfoBo> cityStatInfoBos) {
|
||||
this.cityStatInfoBos = cityStatInfoBos;
|
||||
}
|
||||
|
||||
public CitySellStatBo getCitySellStatBo() {
|
||||
return citySellStatBo;
|
||||
}
|
||||
|
||||
public void setCitySellStatBo(CitySellStatBo citySellStatBo) {
|
||||
this.citySellStatBo = citySellStatBo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@
|
||||
<div class="trend01b">
|
||||
<#if districtStatBo?? || regionStatBo??>
|
||||
<#if districtStatBo??>
|
||||
<div><em><#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>暂无</#if></em><label>上周均价(元/㎡)</label></div>
|
||||
<div><em><#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>暂无</#if></em><label>本周均价(元/㎡)</label></div>
|
||||
<div><em><#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>暂无</#if></em><label>上月均价(元/㎡)</label></div>
|
||||
<div><em><#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>暂无</#if></em><label>本月均价(元/㎡)</label></div>
|
||||
<div style="margin-right:0;"><em class="<#if districtStatBo.districtStat.weekendMarkup/100 gte 0>up<#else>down</#if>"><i></i>${(districtStatBo.districtStat.weekendMarkup/100)?string('0.00')}%</em><label>涨跌幅</label></div>
|
||||
<#elseif regionStatBo??>
|
||||
<div><em>${regionStatBo.lastTimeAvgPrice!}</em><label>上周均价(元/㎡)</label></div>
|
||||
<div><em>${regionStatBo.avgPrice!}</em><label>本周均价(元/㎡)</label></div>
|
||||
<div><em>${regionStatBo.lastTimeAvgPrice!}</em><label>上月均价(元/㎡)</label></div>
|
||||
<div><em>${regionStatBo.avgPrice!}</em><label>本月均价(元/㎡)</label></div>
|
||||
<div style="margin-right:0;"><em class="<#if regionStatBo.weekendMarkup gte 0>up<#else>down</#if>"><i></i>${(regionStatBo.weekendMarkup/100)?string('0.00')}%</em><label>涨跌幅</label></div>
|
||||
</#if>
|
||||
</#if>
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.fangjia.service.bo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class CitySellStatBo implements Serializable {
|
||||
private static final long serialVersionUID = -5310665233447971693L;
|
||||
private String city;
|
||||
private String region;
|
||||
private String block;
|
||||
private int avgPrice;
|
||||
private int weekendMarkup;
|
||||
// Äêͬ±ÈÕǵø
|
||||
private Integer yearMarkup;
|
||||
// Ô»·±ÈÕǵø
|
||||
private Integer monthMarkup;
|
||||
private int month;
|
||||
|
||||
private int lastTimeAvgPrice;
|
||||
private Integer startDate;
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(String block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public int getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(int avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
public int getWeekendMarkup() {
|
||||
return weekendMarkup;
|
||||
}
|
||||
|
||||
public void setWeekendMarkup(int weekendMarkup) {
|
||||
this.weekendMarkup = weekendMarkup;
|
||||
}
|
||||
|
||||
public Integer getYearMarkup() {
|
||||
return yearMarkup;
|
||||
}
|
||||
|
||||
public void setYearMarkup(Integer yearMarkup) {
|
||||
this.yearMarkup = yearMarkup;
|
||||
}
|
||||
|
||||
public Integer getMonthMarkup() {
|
||||
return monthMarkup;
|
||||
}
|
||||
|
||||
public void setMonthMarkup(Integer monthMarkup) {
|
||||
this.monthMarkup = monthMarkup;
|
||||
}
|
||||
|
||||
public int getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(int month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public int getLastTimeAvgPrice() {
|
||||
return lastTimeAvgPrice;
|
||||
}
|
||||
|
||||
public void setLastTimeAvgPrice(int lastTimeAvgPrice) {
|
||||
this.lastTimeAvgPrice = lastTimeAvgPrice;
|
||||
}
|
||||
|
||||
public Integer getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Integer startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.fangjia.service.bo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class RegionSellStatBo implements Serializable {
|
||||
private static final long serialVersionUID = -5310665233447971693L;
|
||||
private String city;
|
||||
private String region;
|
||||
private String block;
|
||||
private int avgPrice;
|
||||
private int weekendMarkup;
|
||||
// Äêͬ±ÈÕǵø
|
||||
private Integer yearMarkup;
|
||||
// Ô»·±ÈÕǵø
|
||||
private Integer monthMarkup;
|
||||
private int month;
|
||||
|
||||
private int lastTimeAvgPrice;
|
||||
private Integer startDate;
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(String block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public int getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(int avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
public int getWeekendMarkup() {
|
||||
return weekendMarkup;
|
||||
}
|
||||
|
||||
public void setWeekendMarkup(int weekendMarkup) {
|
||||
this.weekendMarkup = weekendMarkup;
|
||||
}
|
||||
|
||||
public Integer getYearMarkup() {
|
||||
return yearMarkup;
|
||||
}
|
||||
|
||||
public void setYearMarkup(Integer yearMarkup) {
|
||||
this.yearMarkup = yearMarkup;
|
||||
}
|
||||
|
||||
public Integer getMonthMarkup() {
|
||||
return monthMarkup;
|
||||
}
|
||||
|
||||
public void setMonthMarkup(Integer monthMarkup) {
|
||||
this.monthMarkup = monthMarkup;
|
||||
}
|
||||
|
||||
public int getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(int month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public int getLastTimeAvgPrice() {
|
||||
return lastTimeAvgPrice;
|
||||
}
|
||||
|
||||
public void setLastTimeAvgPrice(int lastTimeAvgPrice) {
|
||||
this.lastTimeAvgPrice = lastTimeAvgPrice;
|
||||
}
|
||||
|
||||
public Integer getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Integer startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+11
@@ -2,7 +2,9 @@ package com.fangjia.service.datastore;
|
||||
|
||||
import com.fangjia.dal.mongo.model.CitySellStat;
|
||||
import com.fangjia.dal.mongo.model.DistrictSellStat;
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -32,4 +34,13 @@ public interface CitySellStatService {
|
||||
* @return
|
||||
*/
|
||||
CitySellStat findCitySellStatByCity(String city);
|
||||
|
||||
List<CitySellStat> findNearCityStat(String city, Integer startDate, int count);
|
||||
|
||||
/**
|
||||
* 查询均价开始的最早时间
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
CitySellStat findStartStat(String city);
|
||||
}
|
||||
|
||||
+35
-7
@@ -1,12 +1,6 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.fangjia.core.util.CacheUtils;
|
||||
import com.fangjia.core.util.DateUtil;
|
||||
@@ -16,9 +10,11 @@ import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.mongo.dao.CitySellStatDao;
|
||||
import com.fangjia.dal.mongo.model.CitySellStat;
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
import com.fangjia.service.bo.DistrictStatBo;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.sothis.core.util.Closure;
|
||||
|
||||
/**
|
||||
@@ -108,4 +104,36 @@ public class CitySellStatServiceImpl implements CitySellStatService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CitySellStat> findNearCityStat(final String city, final Integer startDate, final int count) {
|
||||
return CacheUtils.getValue(this.getClass(), "findNearRegionStat",city+"_"+startDate, CachePolicyEnum.LONG,
|
||||
new Closure<List<CitySellStat>, String>() {
|
||||
@Override
|
||||
public List<CitySellStat> execute(String input) {
|
||||
List<QueryParam> q = new ArrayList<QueryParam>(5);
|
||||
q.add(new QueryParam("city", city));
|
||||
q.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
|
||||
|
||||
List<SortParam> s = new ArrayList<SortParam>();
|
||||
s.add(new SortParam("date", false));
|
||||
return citySellStatDao.findAllByParams(q, s, count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CitySellStat findStartStat(final String city) {
|
||||
return CacheUtils.getValue(this.getClass(), "findStartStat",city, CachePolicyEnum.LONG,
|
||||
new Closure<CitySellStat, String>() {
|
||||
@Override
|
||||
public CitySellStat execute(String input) {
|
||||
List<QueryParam> q = new ArrayList<QueryParam>(5);
|
||||
q.add(new QueryParam("city", city));
|
||||
|
||||
List<SortParam> s = new ArrayList<SortParam>();
|
||||
s.add(new SortParam("date", true));
|
||||
return citySellStatDao.findFirstByParams(q, s);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
import com.fangjia.service.bo.AvgUpdateBo;
|
||||
import com.fangjia.service.bo.RegionStatBo;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface RegionSellService {
|
||||
|
||||
|
||||
}
|
||||
-5
@@ -5,10 +5,5 @@ import java.util.List;
|
||||
import com.fangjia.dal.mongo.model.RegionSellStat;
|
||||
|
||||
public interface RegionSellStatService {
|
||||
|
||||
RegionSellStat findNewestRegionPrice();
|
||||
|
||||
List<RegionSellStat> findAllRegionPriceByCity(String city, Integer date, String sortField, Boolean sortWay);
|
||||
|
||||
RegionSellStat findNewestRegionPrice(String city, String region);
|
||||
}
|
||||
|
||||
-49
@@ -11,55 +11,6 @@ import com.fangjia.dal.mongo.dao.RegionSellStatDao;
|
||||
import com.fangjia.dal.mongo.model.RegionSellStat;
|
||||
|
||||
public class RegionSellStatServiceImpl implements RegionSellStatService {
|
||||
|
||||
private RegionSellStatDao regionSellStatDao;
|
||||
|
||||
public RegionSellStatDao getRegionSellStatDao() {
|
||||
return regionSellStatDao;
|
||||
}
|
||||
|
||||
public void setRegionSellStatDao(RegionSellStatDao regionSellStatDao) {
|
||||
this.regionSellStatDao = regionSellStatDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionSellStat findNewestRegionPrice() {
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("date", false));
|
||||
return regionSellStatDao.findFirstByParams(null, sortParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionSellStat> findAllRegionPriceByCity(String city,
|
||||
Integer date, String sortField, Boolean sortWay) {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", city));
|
||||
params.add(new QueryParam("date", date));
|
||||
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
if(StringUtils.isNotBlank(sortField)){
|
||||
sortParams.add(new SortParam(sortField, sortWay));
|
||||
}else{
|
||||
sortParams.add(new SortParam("mom", false));
|
||||
}
|
||||
|
||||
|
||||
return regionSellStatDao.findAllByParams(params, sortParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionSellStat findNewestRegionPrice(String city, String region) {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", city));
|
||||
params.add(new QueryParam("region", region));
|
||||
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("date", false));
|
||||
return regionSellStatDao.findFirstByParams(params, sortParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user