改造区域均价
This commit is contained in:
+53
-4
@@ -19,6 +19,7 @@ import com.fangjia.coresite.model.*;
|
||||
import com.fangjia.dal.mongo.model.*;
|
||||
import com.fangjia.service.bo.*;
|
||||
import com.fangjia.service.datastore.*;
|
||||
import com.fangjia.service.mongo.fangjia.RegionSellStatService;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@@ -74,6 +75,7 @@ public class TrendController {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TrendController.class);
|
||||
|
||||
private CitySellStatService citySellStatService;
|
||||
private RegionSellStatService regionSellStatService;
|
||||
|
||||
public Object trendChartAction(TrendModel model, HttpServletRequest request) {
|
||||
TrendView trendView = TrendViewFactory.getInstance().create(model);
|
||||
@@ -175,10 +177,10 @@ public class TrendController {
|
||||
//DistrictStatBo statBo = getDistrictStat(new DistrictKey(trendView.getCityName(), trendView.getRegion(), trendView.getDistrictName()));
|
||||
DistrictStatBo statBo = getNearestDistrictStat(new DistrictKey(trendView.getCityName(), trendView.getRegion(), trendView.getDistrictName()));
|
||||
model.setDistrictStatBo(statBo);
|
||||
} else if (trendView.getType().equals(ViewType.region) || trendView.getType().equals(ViewType.block)) {
|
||||
} else if (trendView.getType().equals(ViewType.region)) {
|
||||
//RegionStatBo regionStat = getRegionBlockStat(trendView.getCityName(), trendView.getRegion(), trendView.getBlock());
|
||||
RegionStatBo regionStat = getNearestRegionStat(trendView.getCityName(), trendView.getRegion(), trendView.getBlock());
|
||||
model.setRegionStatBo(regionStat);
|
||||
RegionSellStatBo regionSellStatBo = getNearestRegionSellStat(trendView.getCityName(), trendView.getRegion());
|
||||
model.setRegionSellStatBo(regionSellStatBo);
|
||||
model.setRegion(trendView.getRegion());
|
||||
} else if (trendView.getType().equals(ViewType.city)) {
|
||||
//RegionStatBo regionStat = getRegionBlockStat(trendView.getCityName(), null, null);
|
||||
@@ -670,13 +672,16 @@ public class TrendController {
|
||||
private List<JSONObject> buildStatJson(String city, String region, String block, int weeks) {
|
||||
List<RegionStat> regionStatList = null;
|
||||
List<CitySellStat> citySellStatList = null;
|
||||
List<RegionSellStat> regionSellStatList = null;
|
||||
Map<String, String> oprions = new HashMap<String, String>();
|
||||
Date currentDate = new Date();
|
||||
if (city != null && region != null && block != null) {
|
||||
regionStatList = regionStatService.findRegionStat(city, region, block, currentDate, weeks);
|
||||
oprions.put("name", block + "板块");
|
||||
} else if (city != null && region != null) {
|
||||
regionStatList = regionStatService.findRegionStat(city, region, null, currentDate, weeks);
|
||||
//regionStatList = regionStatService.findRegionStat(city, region, null, currentDate, weeks);
|
||||
int month = weeks / 4;
|
||||
regionSellStatList = regionSellStatService.getAllWithMonths(city, region, month);
|
||||
oprions.put("name", region);
|
||||
} else if (city != null) {
|
||||
//regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks);
|
||||
@@ -703,6 +708,14 @@ public class TrendController {
|
||||
ja.put(re.getAvgPrice());
|
||||
splineJa.put(ja);
|
||||
}
|
||||
} else if (CollectionUtils.isNotEmpty(regionSellStatList)) {
|
||||
for (int i = regionSellStatList.size() - 1; i >= 0; i--) {
|
||||
RegionSellStat re = regionSellStatList.get(i);
|
||||
JSONArray ja = new JSONArray();
|
||||
ja.put(DateUtil.getBeforeDay(DateUtil.parseDate(re.getDate().toString(), "yyyyMM"), -1).getTime());
|
||||
ja.put(re.getAvgPrice());
|
||||
splineJa.put(ja);
|
||||
}
|
||||
}
|
||||
|
||||
if (splineJa.length() > 0) {
|
||||
@@ -854,6 +867,38 @@ public class TrendController {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域均价
|
||||
*
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
private RegionSellStatBo getNearestRegionSellStat(String city, String region) {
|
||||
RegionSellStatBo ret = null;
|
||||
List<RegionSellStat> regionSellStats = null;
|
||||
Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtils.addMonths(new Date(), -3), "yyyyMM"));
|
||||
regionSellStats = regionSellStatService.findNearCityStat(city, region, startDate, 2);
|
||||
if(regionSellStats!=null && regionSellStats.size()>0){
|
||||
RegionSellStatBo bo = new RegionSellStatBo();
|
||||
if(regionSellStats.size()==2){
|
||||
bo.setAvgPrice(regionSellStats.get(0).getAvgPrice());
|
||||
bo.setLastTimeAvgPrice(regionSellStats.get(1).getAvgPrice());
|
||||
int monthMarkup = (regionSellStats.get(0).getAvgPrice()-regionSellStats.get(1).getAvgPrice())*10000/regionSellStats.get(1).getAvgPrice();
|
||||
bo.setMonthMarkup(monthMarkup);
|
||||
|
||||
}else{
|
||||
bo.setAvgPrice(regionSellStats.get(0).getAvgPrice());
|
||||
}
|
||||
|
||||
RegionSellStat rs = regionSellStatService.findStartStat(city, region);
|
||||
if(rs!=null){
|
||||
bo.setStartDate(rs.getDate());
|
||||
}
|
||||
return bo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private RegionStatBo getNearestRegionStat(String city, String region, String block){
|
||||
RegionStatBo ret = null;
|
||||
@@ -1315,4 +1360,8 @@ public class TrendController {
|
||||
public void setCitySellStatService(CitySellStatService citySellStatService) {
|
||||
this.citySellStatService = citySellStatService;
|
||||
}
|
||||
|
||||
public void setRegionSellStatService(RegionSellStatService regionSellStatService) {
|
||||
this.regionSellStatService = regionSellStatService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class TrendModel extends BaseModel implements TrendViewModel {
|
||||
private DistrictStatBo districtStatBo;
|
||||
private RegionStatBo regionStatBo;
|
||||
private CitySellStatBo citySellStatBo;
|
||||
private RegionSellStatBo regionSellStatBo;
|
||||
private String affectKeyword;
|
||||
private int chartWidth;
|
||||
private int chartHeight;
|
||||
@@ -339,4 +340,8 @@ public class TrendModel extends BaseModel implements TrendViewModel {
|
||||
public void setCitySellStatBo(CitySellStatBo citySellStatBo) {
|
||||
this.citySellStatBo = citySellStatBo;
|
||||
}
|
||||
|
||||
public void setRegionSellStatBo(RegionSellStatBo regionSellStatBo) {
|
||||
this.regionSellStatBo = regionSellStatBo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
</#if>
|
||||
|
||||
<div class="trend01b">
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo??>
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??>
|
||||
<#if count??><div><em>${count!}</em><label>楼盘总量</label></div></#if>
|
||||
<#if districtStatBo??>
|
||||
<div><em><#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>暂无</#if></em><label>上周均价(元/㎡)</label></div>
|
||||
@@ -123,6 +123,11 @@
|
||||
<div><em>${citySellStatBo.lastTimeAvgPrice!}</em><label>上月均价(元/㎡)</label></div>
|
||||
<div><em>${citySellStatBo.avgPrice!}</em><label>本月均价(元/㎡)</label></div>
|
||||
<div style="margin-right:0;"><em class="<#if citySellStatBo.monthMarkup gte 0>up<#else>down</#if>"><i></i>${(citySellStatBo.monthMarkup/100)?string('0.00')}%</em><label>涨跌幅</label></div>
|
||||
<#elseif regionSellStatBo??>
|
||||
<div><em>${regionSellStatBo.lastTimeAvgPrice!}</em><label>上月均价(元/㎡)</label></div>
|
||||
<div><em>${regionSellStatBo.avgPrice!}</em><label>本月均价(元/㎡)</label></div>
|
||||
<div style="margin-right:0;"><em class="<#if regionSellStatBo.monthMarkup gte 0>up<#else>down</#if>"><i></i>${(regionSellStatBo.monthMarkup/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>
|
||||
@@ -163,7 +168,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="trend_content">
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo??>
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??>
|
||||
<ul class="chartTools01">
|
||||
<li><a id="exportButton">下载</a></li>
|
||||
<li><a id="printButton">打印</a></li>
|
||||
@@ -185,7 +190,7 @@
|
||||
</#if>
|
||||
<div class="chart" style="padding:20px;">
|
||||
<div id="container">
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo??>
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??>
|
||||
<img class="loading" src="${staticUrl}/images/bgtu/fangjia/trend-loading.gif?v=${version}">
|
||||
<#else>
|
||||
<div class="nofound">
|
||||
@@ -482,7 +487,7 @@
|
||||
var down_pic_temp = 0;
|
||||
$(document).ready(function(){
|
||||
//走势图
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo??>
|
||||
<#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??>
|
||||
<#if type??>
|
||||
<#if type == '4' || type == 'quarter'>
|
||||
var url = Constants.cityUrl + '/trend/quarterData?defaultCityName=${cityName}&districtName=${districtName!}®ion=${region!}&block=${block!}&keyword=${keyword!}';
|
||||
|
||||
+22
@@ -1,9 +1,31 @@
|
||||
package com.fangjia.service.mongo.fangjia;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.dal.mongo.model.CitySellStat;
|
||||
import com.fangjia.dal.mongo.model.RegionSellStat;
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
|
||||
public interface RegionSellStatService {
|
||||
|
||||
/**
|
||||
* 获取过去 monCount 个月的数据(不包含本月数据)
|
||||
* @param city
|
||||
* @param region
|
||||
* @param monthCount
|
||||
* @return
|
||||
*/
|
||||
List<RegionSellStat> getAllWithMonths(String city, String region, int monthCount);
|
||||
|
||||
List<RegionSellStat> findNearCityStat(String city, final String region, Integer startDate, int count);
|
||||
|
||||
/**
|
||||
* 查询均价开始的最早时间
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
RegionSellStat findStartStat(String city, final String region);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+73
@@ -1,16 +1,89 @@
|
||||
package com.fangjia.service.mongo.fangjia;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.core.util.CacheUtils;
|
||||
import com.fangjia.core.util.DateUtil;
|
||||
import com.fangjia.dal.mongo.model.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.RegionSellStatDao;
|
||||
import com.fangjia.dal.mongo.model.RegionSellStat;
|
||||
import org.sothis.core.util.Closure;
|
||||
|
||||
public class RegionSellStatServiceImpl implements RegionSellStatService {
|
||||
|
||||
private RegionSellStatDao regionSellStatDao;
|
||||
|
||||
@Override
|
||||
public List<RegionSellStat> getAllWithMonths(final String city, final String region, final int monthCount) {
|
||||
return CacheUtils.getValue(this.getClass(), "getAllWithMonths",city+"_"+monthCount, CacheUtils.CachePolicyEnum.LONG,
|
||||
new Closure<List<RegionSellStat>, String>() {
|
||||
@Override
|
||||
public List<RegionSellStat> execute(String input) {
|
||||
System.out.println("getAllWithMonths");
|
||||
Date now = new Date();
|
||||
Date lastMonth = DateUtil.getBeforeDate(now, -1);
|
||||
Date monthInLastYear = DateUtil.getBeforeDate(now, -1 * monthCount);
|
||||
int lastMonthNum = DateUtil.getYear(lastMonth) * 100 + DateUtil.getMonth(lastMonth);
|
||||
int monthInLastYearNum = DateUtil.getYear(monthInLastYear) * 100 + DateUtil.getMonth(monthInLastYear);
|
||||
|
||||
List<QueryParam> queryParams = ImmutableList.of(
|
||||
new QueryParam("city", city),
|
||||
new QueryParam("region", region),
|
||||
new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, lastMonthNum),
|
||||
new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, monthInLastYearNum)
|
||||
);
|
||||
List<SortParam> sortParams = ImmutableList.of(
|
||||
new SortParam("date", false)
|
||||
);
|
||||
return regionSellStatDao.findAllByParams(queryParams, sortParams);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionSellStat> findNearCityStat(final String city, final String region, final Integer startDate, final int count) {
|
||||
return CacheUtils.getValue(this.getClass(), "findNearRegionStat",city+"_"+startDate, CacheUtils.CachePolicyEnum.LONG,
|
||||
new Closure<List<RegionSellStat>, String>() {
|
||||
@Override
|
||||
public List<RegionSellStat> execute(String input) {
|
||||
List<QueryParam> q = new ArrayList<QueryParam>(5);
|
||||
q.add(new QueryParam("city", city));
|
||||
q.add(new QueryParam("region", region));
|
||||
q.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
|
||||
|
||||
List<SortParam> s = new ArrayList<SortParam>();
|
||||
s.add(new SortParam("date", false));
|
||||
return regionSellStatDao.findAllByParams(q, s, count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionSellStat findStartStat(final String city, final String region) {
|
||||
return CacheUtils.getValue(this.getClass(), "findStartStat",city, CacheUtils.CachePolicyEnum.LONG,
|
||||
new Closure<RegionSellStat, String>() {
|
||||
@Override
|
||||
public RegionSellStat execute(String input) {
|
||||
List<QueryParam> q = new ArrayList<QueryParam>(5);
|
||||
q.add(new QueryParam("city", city));
|
||||
q.add(new QueryParam("region", region));
|
||||
|
||||
List<SortParam> s = new ArrayList<SortParam>();
|
||||
s.add(new SortParam("date", true));
|
||||
return regionSellStatDao.findFirstByParams(q, s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setRegionSellStatDao(RegionSellStatDao regionSellStatDao) {
|
||||
this.regionSellStatDao = regionSellStatDao;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user