修改代码字符编码

This commit is contained in:
2026-02-24 17:53:50 +08:00
parent 2495fe5f6d
commit c8418c7d4b
5195 changed files with 121754 additions and 121754 deletions
@@ -64,7 +64,7 @@ public class CoredataConfig {
}
/**
* ÊÇ·ñ°ÑÊý¾Ý·ÅÈëÄÚ´æÖÐ
* 是否把数据放入内存中
*
* @return
*/
@@ -1,36 +1,36 @@
package com.fangjia.analysis.bean;
/**
* 房价计算类型定义
* 房价计算类型定义
*
* @author dxy
*
*/
public enum FangjiaCalcEnum {
/**
* 住宅二手房均价
* 住宅二手房均价
*/
SELL("sell", "住宅二手房均价"),
SELL("sell", "住宅二手房均价"),
/**
* 住宅租金均价
* 住宅租金均价
*/
RENT("rent", "住宅租金均价"),
RENT("rent", "住宅租金均价"),
/**
* 商铺出租均价
* 商铺出租均价
*/
SHOP_RENT("shop_rent", "商铺出租均价"),
SHOP_RENT("shop_rent", "商铺出租均价"),
/**
* 商铺出售均价
* 商铺出售均价
*/
SHOP_SELL("shop_sell", "商铺出售均价"),
SHOP_SELL("shop_sell", "商铺出售均价"),
/**
* 写字楼出租均价
* 写字楼出租均价
*/
OFFICE_RENT("office_rent", "写字楼出租均价"),
OFFICE_RENT("office_rent", "写字楼出租均价"),
/**
* 写字楼出售均价
* 写字楼出售均价
*/
OFFICE_SELL("office_sell", "写字楼出售均价"), ;
OFFICE_SELL("office_sell", "写字楼出售均价"), ;
private final String category;
private final String display;
@@ -5,7 +5,7 @@ import java.util.Date;
import com.fangjia.analysis.exceptions.CalcException;
/**
* 均价计算接口
* 均价计算接口
*
* @author xiaoyu
*
@@ -13,11 +13,11 @@ import com.fangjia.analysis.exceptions.CalcException;
public interface Calculator<R extends Result, K> {
/**
* 计算对象(K)均价
* 计算对象(K)均价
*
* @param k
* @param calcDate
* 计算日期
* 计算日期
* @return
* @throws CalcException
*/
@@ -3,7 +3,7 @@ package com.fangjia.analysis.core;
import com.fangjia.analysis.exceptions.ApplyException;
/**
* 计算结果处理器
* 计算结果处理器
*
* @author xiaoyu
*
@@ -13,7 +13,7 @@ import com.fangjia.analysis.exceptions.ApplyException;
public interface Operator<K, R extends Result> {
/**
* 结果处理
* 结果处理
*
* @param k
* @param r
@@ -4,21 +4,21 @@ import java.io.Serializable;
import java.util.Date;
/**
* 元数据
* 元数据
*
* @author xiaoyu
*
*/
public interface Point extends Serializable {
/**
* 值
* 值
*
* @return
*/
public Integer getValue();
/**
* 时间
* 时间
*
* @return
*/
@@ -6,7 +6,7 @@ import java.util.List;
import com.fangjia.analysis.exceptions.FetchException;
/**
* 原始数据提供者
* 原始数据提供者
*
* @author xiaoyu
*
@@ -16,7 +16,7 @@ import com.fangjia.analysis.exceptions.FetchException;
public interface Provider<K, P extends Point> {
/**
* 数据获取
* 数据获取
*
* @param k
* @return
@@ -3,28 +3,28 @@ package com.fangjia.analysis.core;
import java.util.Date;
/**
* 结果定义接口
* 结果定义接口
*
* @author xiaoyu
*
*/
public interface Result {
/**
* 计算值
* 计算值
*
* @return
*/
public int getValue();
/**
* 计算日期
* 计算日期
*
* @return
*/
public Date getCalcDate();
/**
* 计算的可信度
* 计算的可信度
*
* @return
*/
@@ -13,8 +13,8 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
* 写字楼计算命令处理者
* @author 王文艳
* 写字楼计算命令处理者
* @author 王文艳
*/
public class CalcCommandConsumer {
private final static Logger LOGGER = LoggerFactory.getLogger(CalcCommandConsumer.class);
@@ -55,7 +55,7 @@ public class CalcCommandConsumer {
Runnable runnable = null;
if (StringUtils.isNotBlank(calcCommand.getCity()) && StringUtils.isNotBlank(calcCommand.getRegion())
&& StringUtils.isNotBlank(calcCommand.getName())) {// 小区
&& StringUtils.isNotBlank(calcCommand.getName())) {// 小区
}
if (runnable != null) {
@@ -27,7 +27,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* 写字楼租金数据提供者
* 写字楼租金数据提供者
* @author wenyan
*/
public class OfficeRentProvider implements Provider<DistrictKey, OfficeRentPoint> {
@@ -90,7 +90,7 @@ public class OfficeRentProvider implements Provider<DistrictKey, OfficeRentPoint
int c = 0;
for (String name : names) {
if (StringUtils.isNotBlank(name)) {
if (name.indexOf("(") > -1 || name.indexOf(")") > -1 || name.indexOf("(") > -1 || name.indexOf(")") > -1
if (name.indexOf("(") > -1 || name.indexOf(")") > -1 || name.indexOf("(") > -1 || name.indexOf(")") > -1
| name.indexOf("[") > -1 || name.indexOf("]") > -1 || name.indexOf("-") > -1 || name.indexOf("{") > -1
|| name.indexOf("}") > -1 || name.indexOf("{") > -1 || name.indexOf("}") > -1 || name.indexOf(":") > -1) {
continue;
@@ -35,7 +35,7 @@ import java.net.UnknownHostException;
import java.util.*;
/**
* 二手房价格计算命令处理者
* 二手房价格计算命令处理者
*
* @author xiaoyu
*/
@@ -155,9 +155,9 @@ public class CalcCommandConsumer extends Thread {
public static void main(String[] args) throws Exception {
CalcCommandConsumer sd = new CalcCommandConsumer(null);
List<String> cities = Arrays.asList(
"广州","北京","上海","深圳","成都","西安","天津","杭州","武汉","南京","沈阳","重庆","贵阳","福州","宁波","石家庄","大连","昆明","苏州","长沙","太原","厦门","无锡","郑州","呼和浩特","兰州","哈尔滨","济南","佛山","长春","青岛","东莞","合肥","乌鲁木齐","烟台","南昌","泉州","齐齐哈尔","包头","常德","大同","温州","银川","西宁","扬州","绵阳","威海","吉林","邯郸",
"中山","湛江","潍坊","保定","秦皇岛","常州","宜昌","鞍山","嘉兴","大庆","徐州","株洲","镇江","赣州","芜湖","南通","九江","泰州","洛阳","台州","惠州","湖州","江门","绍兴","海口","珠海","金华","连云港","桂林","马鞍山","柳州","淄博","盐城","本溪","汕头","衡阳","揭阳","茂名","牡丹江","平顶山","舟山","安阳","岳阳","许昌","四平","淮南","淮安","赤峰","佳木斯","南阳","临沂","临汾","榆林","咸阳","唐山","三亚","宜宾","自贡","廊坊","攀枝花","南宁","延安","襄阳","丽江","大理","六盘水","湘潭","清远","衢州","宿迁","北海","莆田","玉林","张家界","玉溪","云浮","肇庆",
"新乡","营口","潮州","黄石","焦作","盘锦","梅州","曲靖","阳江","韶关","河源","遵义","伊犁","阿拉善盟","锡林郭勒盟","兴安盟","林芝","阿里","那曲","山南","日喀则","昌都","红河","中卫","双鸭山","克孜勒苏","巴音郭楞","博尔塔拉","阿勒泰","昌吉","和田","哈密","吐鲁番","文山州","武威","铁岭","天水","泰安","黄冈","广元","阜阳","定西","辽源","丽水","乐山","菏泽","锦州","汉中","黄山","白山","安顺","安康","绥化","钦州","鄂尔多斯","梧州","百色","鸡西","七台河","白城","朝阳","亳州","安庆","六安","宁德","三沙","临沧","拉萨","南充","泸州","资阳","乌海","开封","固原","朔州","平凉","白银","吉安","通化","景德镇","鹤岗","铜仁","南平","贵港","商洛","吴忠","晋城","阿克苏","海东","黑河","阜新","抚顺","葫芦岛","张家口","衡水","邢台","石嘴山","济宁","日照","聊城","滨州","淮北","宣城","三明","宿州","龙岩","保山","池州","乌兰察布","内江","达州","贺州","巴中","昭通","怀化","鄂州","伊春","毕节","十堰","遂宁","漯河","松原","眉山","鹤壁","忻州","郴州","晋中","益阳","辽阳","宝鸡","酒泉","张掖","随州","承德","鹰潭","新余","孝感","枣庄","周口","濮阳","莱芜","阳泉","运城","蚌埠","渭南","滁州","铜陵","嘉峪关","漳州","庆阳","汕尾","上饶","普洱","沧州","宜春","德阳","东营","广安","德州","雅安","永州","娄底","荆州","咸宁","三门峡","商丘","长治","吕梁","金昌","陇南","萍乡","抚州","通辽","楚雄","临夏","甘南","黔西南","黔东南","湘西","延边","海北州","黄南州","海南州","果洛州","玉树州","海西州","阿坝州","凉山州","怒江州","巴彦淖尔","来宾","信阳","克拉玛依","河池","邵阳","荆门","防城港","驻马店","铜川","崇左","呼伦贝尔","大兴安岭","甘孜州","西双版纳州","德宏州","喀什","恩施","塔城","黔南","迪庆州","丹东","石河子","阿拉尔","图木舒克","五家渠","济源","仙桃","潜江","天门","神农架","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","北屯","铁门关","双河","可克达拉");
"广州","北京","上海","深圳","成都","西安","天津","杭州","武汉","南京","沈阳","重庆","贵阳","福州","宁波","石家庄","大连","昆明","苏州","长沙","太原","厦门","无锡","郑州","呼和浩特","兰州","哈尔滨","济南","佛山","长春","青岛","东莞","合肥","乌鲁木齐","烟台","南昌","泉州","齐齐哈尔","包头","常德","大同","温州","银川","西宁","扬州","绵阳","威海","吉林","邯郸",
"中山","湛江","潍坊","保定","秦皇岛","常州","宜昌","鞍山","嘉兴","大庆","徐州","株洲","镇江","赣州","芜湖","南通","九江","泰州","洛阳","台州","惠州","湖州","江门","绍兴","海口","珠海","金华","连云港","桂林","马鞍山","柳州","淄博","盐城","本溪","汕头","衡阳","揭阳","茂名","牡丹江","平顶山","舟山","安阳","岳阳","许昌","四平","淮南","淮安","赤峰","佳木斯","南阳","临沂","临汾","榆林","咸阳","唐山","三亚","宜宾","自贡","廊坊","攀枝花","南宁","延安","襄阳","丽江","大理","六盘水","湘潭","清远","衢州","宿迁","北海","莆田","玉林","张家界","玉溪","云浮","肇庆",
"新乡","营口","潮州","黄石","焦作","盘锦","梅州","曲靖","阳江","韶关","河源","遵义","伊犁","阿拉善盟","锡林郭勒盟","兴安盟","林芝","阿里","那曲","山南","日喀则","昌都","红河","中卫","双鸭山","克孜勒苏","巴音郭楞","博尔塔拉","阿勒泰","昌吉","和田","哈密","吐鲁番","文山州","武威","铁岭","天水","泰安","黄冈","广元","阜阳","定西","辽源","丽水","乐山","菏泽","锦州","汉中","黄山","白山","安顺","安康","绥化","钦州","鄂尔多斯","梧州","百色","鸡西","七台河","白城","朝阳","亳州","安庆","六安","宁德","三沙","临沧","拉萨","南充","泸州","资阳","乌海","开封","固原","朔州","平凉","白银","吉安","通化","景德镇","鹤岗","铜仁","南平","贵港","商洛","吴忠","晋城","阿克苏","海东","黑河","阜新","抚顺","葫芦岛","张家口","衡水","邢台","石嘴山","济宁","日照","聊城","滨州","淮北","宣城","三明","宿州","龙岩","保山","池州","乌兰察布","内江","达州","贺州","巴中","昭通","怀化","鄂州","伊春","毕节","十堰","遂宁","漯河","松原","眉山","鹤壁","忻州","郴州","晋中","益阳","辽阳","宝鸡","酒泉","张掖","随州","承德","鹰潭","新余","孝感","枣庄","周口","濮阳","莱芜","阳泉","运城","蚌埠","渭南","滁州","铜陵","嘉峪关","漳州","庆阳","汕尾","上饶","普洱","沧州","宜春","德阳","东营","广安","德州","雅安","永州","娄底","荆州","咸宁","三门峡","商丘","长治","吕梁","金昌","陇南","萍乡","抚州","通辽","楚雄","临夏","甘南","黔西南","黔东南","湘西","延边","海北州","黄南州","海南州","果洛州","玉树州","海西州","阿坝州","凉山州","怒江州","巴彦淖尔","来宾","信阳","克拉玛依","河池","邵阳","荆门","防城港","驻马店","铜川","崇左","呼伦贝尔","大兴安岭","甘孜州","西双版纳州","德宏州","喀什","恩施","塔城","黔南","迪庆州","丹东","石河子","阿拉尔","图木舒克","五家渠","济源","仙桃","潜江","天门","神农架","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","北屯","铁门关","双河","可克达拉");
int c = 0;
for(String city : cities) {
int k = 0;
@@ -177,7 +177,7 @@ public class CalcCommandConsumer extends Thread {
command.setCity(city);
command.setRegion(region);
command.setName(name);
command.setEstateType("普通住宅");
command.setEstateType("普通住宅");
command.setCalcType(0);
command.setCalcDate(DateUtil.parseDate("2017-01-01", "yyyy-MM-dd"));
command.setId(ObjectId.get().toString());
@@ -188,14 +188,14 @@ public class CalcCommandConsumer extends Thread {
}
/**
* 开始消耗计算指令
* 开始消耗计算指令
*
* @param command
* @throws Exception
*/
private void doConsumer(CalcCommand command) throws Exception {
long startMills = System.currentTimeMillis();
//计算某一天的均价
//计算某一天的均价
if (command.getCalcType() == CalcCommand.CalcTypeEnum.CALC_BY_DATE.getCalcType()) {
if (command.getCalcDate() == null) {
commandService.updateToErr(command.getId());
@@ -220,7 +220,7 @@ public class CalcCommandConsumer extends Thread {
Calculator calculator = null;
Operator operator = null;
Serializable calcKey = null;
if (command.isCommandOfDistrict()) {// 小区
if (command.isCommandOfDistrict()) {// 小区
calcKey = new DistrictKey(command.getCity(), command.getRegion(), command.getName(), command.getEstateType());
calculator = new DistrictSellCalculator();
operator = new DistrictSellOperator();
@@ -244,7 +244,7 @@ public class CalcCommandConsumer extends Thread {
} else {
throw new CalcException("can't find calculator or operator or calcKey!");
}
} else if (command.getCalcType() == CalcCommand.CalcTypeEnum.CALC_ALL_WEEKS.getCalcType()) {//重算某个小区的所有均价
} else if (command.getCalcType() == CalcCommand.CalcTypeEnum.CALC_ALL_WEEKS.getCalcType()) {//重算某个小区的所有均价
if (command.isCommandOfDistrict()) {
if (reCalcluatorAll(new DistrictKey(command.getCity(), command.getRegion(), command.getName(), command.getEstateType()))) {
commandService.updateToCalcSuc(command.getId());
@@ -261,7 +261,7 @@ public class CalcCommandConsumer extends Thread {
}
/**
* 重算指定小区的所有价格
* 重算指定小区的所有价格
*
* @param districtKey
* @return
@@ -275,14 +275,14 @@ public class CalcCommandConsumer extends Thread {
String name = districtKey.getName();
String estateType = districtKey.getEstateTypeEnum().getEstateType();
// 查出配置信息
// 查出配置信息
CalcConfig calcConfig = calcConfigDao.findCalcConfig(city, region, name, "district", estateType);
// 删除之前所有价格
// 删除之前所有价格
districtStatDao.deleteAll(city, region, name, estateType);
calcDistrictStatDao.deleteAll(city, region, name, estateType);
// 计算日期的起始点
// 计算日期的起始点
Date leftDate = getLeftDate(calcConfig);
Date rightDate = new Date();
List<Date> weekends = DateUtil.getWeekendBetweenDates(leftDate, rightDate);
@@ -309,7 +309,7 @@ public class CalcCommandConsumer extends Thread {
}
}
// 如果数据库中的价格开始时间早于样本开始时间,则该时间段的价格需要模拟出来
// 如果数据库中的价格开始时间早于样本开始时间,则该时间段的价格需要模拟出来
if (rebool && startRes != null && calcConfig != null && calcConfig.getCalcStartDate() != null &&
calcConfig.getStatStartDate() != null && calcConfig.getCalcStartDate().before(calcConfig.getStatStartDate())) {
List<Date> derivationWeekends = DateUtil.getWeekendBetweenDates(calcConfig.getCalcStartDate(), calcConfig.getStatStartDate());
@@ -339,7 +339,7 @@ public class CalcCommandConsumer extends Thread {
}
private Date getLeftDate(CalcConfig calcConfig) {
// 优先使用样本开始时间
// 优先使用样本开始时间
if (calcConfig != null && calcConfig.getStatStartDate() != null) {
if(calcConfig.getStatStartDate().before(CALC_START_DATE)) {
return CALC_START_DATE;
@@ -35,7 +35,7 @@ import java.net.UnknownHostException;
import java.util.*;
/**
* 二手房价格计算命令处理者
* 二手房价格计算命令处理者
*
* @author xiaoyu
*/
@@ -154,9 +154,9 @@ public class CalcCommandConsumerTest {
public static void main(String[] args) throws Exception {
CalcCommandConsumerTest sd = new CalcCommandConsumerTest(null);
List<String> cities = Arrays.asList(
"广州","北京","上海","深圳","成都","西安","天津","杭州","武汉","南京","沈阳","重庆","贵阳","福州","宁波","石家庄","大连","昆明","苏州","长沙","太原","厦门","无锡","郑州","呼和浩特","兰州","哈尔滨","济南","佛山","长春","青岛","东莞","合肥","乌鲁木齐","烟台","南昌","泉州","齐齐哈尔","包头","常德","大同","温州","银川","西宁","扬州","绵阳","威海","吉林","邯郸",
"中山","湛江","潍坊","保定","秦皇岛","常州","宜昌","鞍山","嘉兴","大庆","徐州","株洲","镇江","赣州","芜湖","南通","九江","泰州","洛阳","台州","惠州","湖州","江门","绍兴","海口","珠海","金华","连云港","桂林","马鞍山","柳州","淄博","盐城","本溪","汕头","衡阳","揭阳","茂名","牡丹江","平顶山","舟山","安阳","岳阳","许昌","四平","淮南","淮安","赤峰","佳木斯","南阳","临沂","临汾","榆林","咸阳","唐山","三亚","宜宾","自贡","廊坊","攀枝花","南宁","延安","襄阳","丽江","大理","六盘水","湘潭","清远","衢州","宿迁","北海","莆田","玉林","张家界","玉溪","云浮","肇庆",
"新乡","营口","潮州","黄石","焦作","盘锦","梅州","曲靖","阳江","韶关","河源","遵义","伊犁","阿拉善盟","锡林郭勒盟","兴安盟","林芝","阿里","那曲","山南","日喀则","昌都","红河","中卫","双鸭山","克孜勒苏","巴音郭楞","博尔塔拉","阿勒泰","昌吉","和田","哈密","吐鲁番","文山州","武威","铁岭","天水","泰安","黄冈","广元","阜阳","定西","辽源","丽水","乐山","菏泽","锦州","汉中","黄山","白山","安顺","安康","绥化","钦州","鄂尔多斯","梧州","百色","鸡西","七台河","白城","朝阳","亳州","安庆","六安","宁德","三沙","临沧","拉萨","南充","泸州","资阳","乌海","开封","固原","朔州","平凉","白银","吉安","通化","景德镇","鹤岗","铜仁","南平","贵港","商洛","吴忠","晋城","阿克苏","海东","黑河","阜新","抚顺","葫芦岛","张家口","衡水","邢台","石嘴山","济宁","日照","聊城","滨州","淮北","宣城","三明","宿州","龙岩","保山","池州","乌兰察布","内江","达州","贺州","巴中","昭通","怀化","鄂州","伊春","毕节","十堰","遂宁","漯河","松原","眉山","鹤壁","忻州","郴州","晋中","益阳","辽阳","宝鸡","酒泉","张掖","随州","承德","鹰潭","新余","孝感","枣庄","周口","濮阳","莱芜","阳泉","运城","蚌埠","渭南","滁州","铜陵","嘉峪关","漳州","庆阳","汕尾","上饶","普洱","沧州","宜春","德阳","东营","广安","德州","雅安","永州","娄底","荆州","咸宁","三门峡","商丘","长治","吕梁","金昌","陇南","萍乡","抚州","通辽","楚雄","临夏","甘南","黔西南","黔东南","湘西","延边","海北州","黄南州","海南州","果洛州","玉树州","海西州","阿坝州","凉山州","怒江州","巴彦淖尔","来宾","信阳","克拉玛依","河池","邵阳","荆门","防城港","驻马店","铜川","崇左","呼伦贝尔","大兴安岭","甘孜州","西双版纳州","德宏州","喀什","恩施","塔城","黔南","迪庆州","丹东","石河子","阿拉尔","图木舒克","五家渠","济源","仙桃","潜江","天门","神农架","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","北屯","铁门关","双河","可克达拉");
"广州","北京","上海","深圳","成都","西安","天津","杭州","武汉","南京","沈阳","重庆","贵阳","福州","宁波","石家庄","大连","昆明","苏州","长沙","太原","厦门","无锡","郑州","呼和浩特","兰州","哈尔滨","济南","佛山","长春","青岛","东莞","合肥","乌鲁木齐","烟台","南昌","泉州","齐齐哈尔","包头","常德","大同","温州","银川","西宁","扬州","绵阳","威海","吉林","邯郸",
"中山","湛江","潍坊","保定","秦皇岛","常州","宜昌","鞍山","嘉兴","大庆","徐州","株洲","镇江","赣州","芜湖","南通","九江","泰州","洛阳","台州","惠州","湖州","江门","绍兴","海口","珠海","金华","连云港","桂林","马鞍山","柳州","淄博","盐城","本溪","汕头","衡阳","揭阳","茂名","牡丹江","平顶山","舟山","安阳","岳阳","许昌","四平","淮南","淮安","赤峰","佳木斯","南阳","临沂","临汾","榆林","咸阳","唐山","三亚","宜宾","自贡","廊坊","攀枝花","南宁","延安","襄阳","丽江","大理","六盘水","湘潭","清远","衢州","宿迁","北海","莆田","玉林","张家界","玉溪","云浮","肇庆",
"新乡","营口","潮州","黄石","焦作","盘锦","梅州","曲靖","阳江","韶关","河源","遵义","伊犁","阿拉善盟","锡林郭勒盟","兴安盟","林芝","阿里","那曲","山南","日喀则","昌都","红河","中卫","双鸭山","克孜勒苏","巴音郭楞","博尔塔拉","阿勒泰","昌吉","和田","哈密","吐鲁番","文山州","武威","铁岭","天水","泰安","黄冈","广元","阜阳","定西","辽源","丽水","乐山","菏泽","锦州","汉中","黄山","白山","安顺","安康","绥化","钦州","鄂尔多斯","梧州","百色","鸡西","七台河","白城","朝阳","亳州","安庆","六安","宁德","三沙","临沧","拉萨","南充","泸州","资阳","乌海","开封","固原","朔州","平凉","白银","吉安","通化","景德镇","鹤岗","铜仁","南平","贵港","商洛","吴忠","晋城","阿克苏","海东","黑河","阜新","抚顺","葫芦岛","张家口","衡水","邢台","石嘴山","济宁","日照","聊城","滨州","淮北","宣城","三明","宿州","龙岩","保山","池州","乌兰察布","内江","达州","贺州","巴中","昭通","怀化","鄂州","伊春","毕节","十堰","遂宁","漯河","松原","眉山","鹤壁","忻州","郴州","晋中","益阳","辽阳","宝鸡","酒泉","张掖","随州","承德","鹰潭","新余","孝感","枣庄","周口","濮阳","莱芜","阳泉","运城","蚌埠","渭南","滁州","铜陵","嘉峪关","漳州","庆阳","汕尾","上饶","普洱","沧州","宜春","德阳","东营","广安","德州","雅安","永州","娄底","荆州","咸宁","三门峡","商丘","长治","吕梁","金昌","陇南","萍乡","抚州","通辽","楚雄","临夏","甘南","黔西南","黔东南","湘西","延边","海北州","黄南州","海南州","果洛州","玉树州","海西州","阿坝州","凉山州","怒江州","巴彦淖尔","来宾","信阳","克拉玛依","河池","邵阳","荆门","防城港","驻马店","铜川","崇左","呼伦贝尔","大兴安岭","甘孜州","西双版纳州","德宏州","喀什","恩施","塔城","黔南","迪庆州","丹东","石河子","阿拉尔","图木舒克","五家渠","济源","仙桃","潜江","天门","神农架","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","北屯","铁门关","双河","可克达拉");
int c = 0;
for(String city : cities) {
int k = 0;
@@ -176,7 +176,7 @@ public class CalcCommandConsumerTest {
command.setCity(city);
command.setRegion(region);
command.setName(name);
command.setEstateType("普通住宅");
command.setEstateType("普通住宅");
command.setCalcType(0);
command.setCalcDate(DateUtil.parseDate("2017-01-01", "yyyy-MM-dd"));
command.setId(ObjectId.get().toString());
@@ -187,14 +187,14 @@ public class CalcCommandConsumerTest {
}
/**
* 开始消耗计算指令
* 开始消耗计算指令
*
* @param command
* @throws Exception
*/
private void doConsumer(CalcCommand command) throws Exception {
long startMills = System.currentTimeMillis();
//计算某一天的均价
//计算某一天的均价
if (command.getCalcType() == CalcCommand.CalcTypeEnum.CALC_BY_DATE.getCalcType()) {
// if (command.getCalcDate() == null) {
// commandService.updateToErr(command.getId());
@@ -219,7 +219,7 @@ public class CalcCommandConsumerTest {
Calculator calculator = null;
Operator operator = null;
Serializable calcKey = null;
if (command.isCommandOfDistrict()) {// 小区
if (command.isCommandOfDistrict()) {// 小区
calcKey = new DistrictKey(command.getCity(), command.getRegion(), command.getName(), command.getEstateType());
calculator = new DistrictSellCalculator();
operator = new DistrictSellOperator();
@@ -243,7 +243,7 @@ public class CalcCommandConsumerTest {
} else {
throw new CalcException("can't find calculator or operator or calcKey!");
}
} else if (command.getCalcType() == CalcCommand.CalcTypeEnum.CALC_ALL_WEEKS.getCalcType()) {//重算某个小区的所有均价
} else if (command.getCalcType() == CalcCommand.CalcTypeEnum.CALC_ALL_WEEKS.getCalcType()) {//重算某个小区的所有均价
if (command.isCommandOfDistrict()) {
if (reCalcluatorAll(new DistrictKey(command.getCity(), command.getRegion(), command.getName(), command.getEstateType()))) {
// commandService.updateToCalcSuc(command.getId());
@@ -260,7 +260,7 @@ public class CalcCommandConsumerTest {
}
/**
* 重算指定小区的所有价格
* 重算指定小区的所有价格
*
* @param districtKey
* @return
@@ -274,14 +274,14 @@ public class CalcCommandConsumerTest {
String name = districtKey.getName();
String estateType = districtKey.getEstateTypeEnum().getEstateType();
// 查出配置信息
// 查出配置信息
CalcConfig calcConfig = calcConfigDao.findCalcConfig(city, region, name, "district", estateType);
// 删除之前所有价格
// 删除之前所有价格
districtStatDao.deleteAll(city, region, name, estateType);
calcDistrictStatDao.deleteAll(city, region, name, estateType);
// 计算日期的起始点
// 计算日期的起始点
Date leftDate = getLeftDate(calcConfig);
Date rightDate = new Date();
List<Date> weekends = DateUtil.getWeekendBetweenDates(leftDate, rightDate);
@@ -308,7 +308,7 @@ public class CalcCommandConsumerTest {
}
}
// 如果数据库中的价格开始时间早于样本开始时间,则该时间段的价格需要模拟出来
// 如果数据库中的价格开始时间早于样本开始时间,则该时间段的价格需要模拟出来
if (rebool && startRes != null && calcConfig != null && calcConfig.getCalcStartDate() != null &&
calcConfig.getStatStartDate() != null && calcConfig.getCalcStartDate().before(calcConfig.getStatStartDate())) {
List<Date> derivationWeekends = DateUtil.getWeekendBetweenDates(calcConfig.getCalcStartDate(), calcConfig.getStatStartDate());
@@ -338,7 +338,7 @@ public class CalcCommandConsumerTest {
}
private Date getLeftDate(CalcConfig calcConfig) {
// 优先使用样本开始时间
// 优先使用样本开始时间
if (calcConfig != null && calcConfig.getStatStartDate() != null) {
if(calcConfig.getStatStartDate().before(CALC_START_DATE)) {
return CALC_START_DATE;
@@ -12,7 +12,7 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
* 二手房价格计算命令提供者
* 二手房价格计算命令提供者
*
* @author xiaoyu
*/
@@ -38,7 +38,7 @@ public class CalcCommandQueueProvider {
return;
}
//把已经状态改变的指令,重新设为初始化
//把已经状态改变的指令,重新设为初始化
calcCommandDao.updateCalcingToInit(FangjiaCalcEnum.SELL.getCategory());
new AsyncThread(3 * 1000, new AsyncThread.Call() {
@@ -158,7 +158,7 @@ public class TransferDataConsumer {
udata.put("city", command.getCity());
udata.put("region", command.getRegion());
udata.put("district_name", command.getName());
udata.put("estate_type", (command.getEstateType() != null && command.getEstateType().indexOf("±ðÊû") > -1 ? "±ðÊû" : "Ð¡Çø"));
udata.put("estate_type", (command.getEstateType() != null && command.getEstateType().indexOf("别墅") > -1 ? "别墅" : "小区"));
districtStatDao.updateById(udata ,id);
}
@@ -41,7 +41,7 @@ public class TrendMonitorConsumer {
private CalcCommandDao calcCommandDao = CalcCommandDao.getInstance();
private DistrictStatDao districtStatDao = DistrictStatDao.getInstance();
private CalcCommandService calcCommandService = CalcCommandService.getInstance();
// 计算值最大允许的涨跌幅
// 计算值最大允许的涨跌幅
public static final double MAX_CALC_MARKUP = 0.020;
private static TrendMonitorConsumer instance = new TrendMonitorConsumer();
@@ -54,7 +54,7 @@ public class TrendMonitorConsumer {
}
public void start() {
//把计算完成的指令,放入待处理的队列中
//把计算完成的指令,放入待处理的队列中
collector();
for (int i = 1; i <= MONITOR_THREAD_SIZE; i++) {
@@ -86,7 +86,7 @@ public class TrendMonitorConsumer {
}
/**
* 把计算完成的指令,放入待处理的队列中
* 把计算完成的指令,放入待处理的队列中
*/
public void collector() {
calcCommandDao.updateReingToCalcSuc(COMMAND_CATEGORY);
@@ -136,32 +136,32 @@ public class TrendMonitorConsumer {
}
public static void main(String[] args) {
String city = "中山";
String region = "五桂山";
String name = "雅居乐长堤半岛";
String city = "中山";
String region = "五桂山";
String name = "雅居乐长堤半岛";
TrendMonitorConsumer sd = new TrendMonitorConsumer();
CalcCommand command = new CalcCommand();
command.setCity(city);
command.setRegion(region);
command.setName(name);
command.setEstateType("普通住宅");
command.setEstateType("普通住宅");
command.setCalcType(1);
command.setId(ObjectId.get().toString());
sd.startRedraw(command);
}
/**
* 检查是否有需要回溯的指令
* 检查是否有需要回溯的指令
*
* @throws InterruptedException
*/
public void startRedraw(CalcCommand command) {
long lstart = System.currentTimeMillis();
Date startRedrawDate = command.getCalcDate();
String estateType = (command.getEstateType() != null && command.getEstateType().indexOf("别墅") > -1 ? "别墅" : "普通住宅");
String estateType = (command.getEstateType() != null && command.getEstateType().indexOf("别墅") > -1 ? "别墅" : "普通住宅");
if (command.getCalcType() != null && CalcCommand.CalcTypeEnum.CALC_ALL_WEEKS.getCalcType() == command.getCalcType()) {
if (command.isCommandOfDistrict()) {// 小区
if (command.isCommandOfDistrict()) {// 小区
DistrictStat districtStat = districtStatDao.findNewestDistrictStat(command.getCity(), command.getRegion(), command.getName(), estateType);
if (districtStat != null) {
startRedrawDate = districtStat.getWeekend();
@@ -175,13 +175,13 @@ public class TrendMonitorConsumer {
}
int updateSize = 0;
if (command.isCommandOfDistrict()) {// 小区
if (command.isCommandOfDistrict()) {// 小区
updateSize = redrawTrend(command.getCity(), command.getRegion(), command.getName(), estateType, startRedrawDate);
} else if (command.isCommandOfBlock()) {//板块
} else if (command.isCommandOfBlock()) {//板块
updateSize = redrawTrend(command.getCity(), command.getRegion(), command.getBlock(), startRedrawDate);
} else if (command.isCommandOfRegion()) {//区域
} else if (command.isCommandOfRegion()) {//区域
updateSize = redrawTrend(command.getCity(), command.getRegion(), null, startRedrawDate);
} else if (command.isCommandOfCity()) {//城市
} else if (command.isCommandOfCity()) {//城市
updateSize = redrawTrend(command.getCity(), null, null, startRedrawDate);
}
@@ -191,7 +191,7 @@ public class TrendMonitorConsumer {
/**
* 城市曲线回溯
* 城市曲线回溯
*
* @param city
* @param region
@@ -212,7 +212,7 @@ public class TrendMonitorConsumer {
int baseValue = recentlyStat.getCalcValue();
int calcValue = recentlyStat.getCalcValue();
// 数据更新器
// 数据更新器
StatUpdater statUpdater = new StatUpdater(regionStatDao);
for (Date weekend : weekendRegionStatMap.keySet()) {
if (weekend.equals(calcDate)) {
@@ -220,7 +220,7 @@ public class TrendMonitorConsumer {
}
RegionStat stat = weekendRegionStatMap.get(weekend);
// 以前的数据中没有calc_value这个字段,所以就把以前的显示值当做计算值
// 以前的数据中没有calc_value这个字段,所以就把以前的显示值当做计算值
if (stat.getCalcValue() <= 0) {
stat.setCalcValue(stat.getAvgPrice());
}
@@ -240,20 +240,20 @@ public class TrendMonitorConsumer {
newValue = stat.getCalcValue();
}
// 判断是否发生变化
// 判断是否发生变化
if (newValue != stat.getAvgPrice()) {
// 如果价格有更新,那么本周的涨跌幅和下周的涨跌幅应该发生变化
// 如果价格有更新,那么本周的涨跌幅和下周的涨跌幅应该发生变化
RegionStat lastStat = weekendRegionStatMap.get(DateUtil.getLastSunday(weekend));
RegionStat nextStat = weekendRegionStatMap.get(DateUtil.getNextSunday(weekend));
statUpdater.update(stat.getId(), new BasicDBObject("avg_price", newValue));
// 本周的涨跌幅发生变化
// 本周的涨跌幅发生变化
if (lastStat != null) {
statUpdater.update(stat.getId(),
new BasicDBObject("weekend_markup", getWeekendMarkup(newValue, lastStat.getAvgPrice())));
}
// 下周的涨跌幅发生变化
// 下周的涨跌幅发生变化
if (nextStat != null) {
statUpdater.update(nextStat.getId(),
new BasicDBObject("weekend_markup", getWeekendMarkup(nextStat.getAvgPrice(), newValue)));
@@ -267,14 +267,14 @@ public class TrendMonitorConsumer {
}
}
// 确认更新
// 确认更新
statUpdater.commit();
return statUpdater.getUpdateMapSize();
}
/**
* 小区曲线回溯
* 小区曲线回溯
*
* @param city
* @param region
@@ -300,7 +300,7 @@ public class TrendMonitorConsumer {
int baseValue = recentlyStat.getCalcValue();
int calcValue = recentlyStat.getCalcValue();
// 数据更新器
// 数据更新器
StatUpdater statUpdater = new StatUpdater(districtStatDao);
for (Date weekend : weekendDistrictStatMap.keySet()) {
@@ -309,7 +309,7 @@ public class TrendMonitorConsumer {
}
DistrictStat stat = weekendDistrictStatMap.get(weekend);
// 以前的数据中没有calc_value这个字段,所以就把以前的显示值当做计算值
// 以前的数据中没有calc_value这个字段,所以就把以前的显示值当做计算值
if (stat.getCalcValue() <= 0) {
stat.setCalcValue(stat.getAvgPrice());
}
@@ -331,20 +331,20 @@ public class TrendMonitorConsumer {
newValue = stat.getCalcValue();
}
// 判断是否发生变化
// 判断是否发生变化
if (newValue != stat.getAvgPrice()) {
// 如果价格有更新,那么本周的涨跌幅和下周的涨跌幅应该发生变化
// 如果价格有更新,那么本周的涨跌幅和下周的涨跌幅应该发生变化
DistrictStat lastDistrictStat = weekendDistrictStatMap.get(DateUtil.getLastSunday(weekend));
DistrictStat nextDistrictStat = weekendDistrictStatMap.get(DateUtil.getNextSunday(weekend));
statUpdater.update(stat.getId(), new BasicDBObject("avg_price", newValue));
// 本周的涨跌幅发生变化
// 本周的涨跌幅发生变化
if (lastDistrictStat != null) {
statUpdater.update(stat.getId(),
new BasicDBObject("weekend_markup", getWeekendMarkup(newValue, lastDistrictStat.getAvgPrice())));
}
// 下周的涨跌幅发生变化
// 下周的涨跌幅发生变化
if (nextDistrictStat != null) {
statUpdater.update(nextDistrictStat.getId(),
new BasicDBObject("weekend_markup", getWeekendMarkup(nextDistrictStat.getAvgPrice(), newValue)));
@@ -357,7 +357,7 @@ public class TrendMonitorConsumer {
calcValue = stat.getCalcValue();
}
}
// 确认更新
// 确认更新
statUpdater.commit();
return statUpdater.getUpdateMapSize();
@@ -414,7 +414,7 @@ public class TrendMonitorConsumer {
}
/**
* 数据更新对象
* 数据更新对象
*
* @author dxy
*/
@@ -428,7 +428,7 @@ public class TrendMonitorConsumer {
}
/**
* 请求更新
* 请求更新
*
* @param id
* @param data
@@ -448,7 +448,7 @@ public class TrendMonitorConsumer {
}
/**
* 确认之前的请求进行提交
* 确认之前的请求进行提交
*/
public void commit() {
if (updateDataMap.size() <= 0) {
@@ -17,7 +17,7 @@ import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
/**
* 城市价格计算器实现
* 城市价格计算器实现
*
* @author duxiaoyu
*
@@ -28,7 +28,7 @@ public class CitySellCalculator implements Calculator<CitySellResult, CityKey> {
private CitySellProvider provider = CitySellProvider.getInstance();
public static void main(String[] args) throws CalcException {
CitySellCalculator calculator = new CitySellCalculator();
String city = "天津";
String city = "天津";
Date date1 = DateUtil.parseDate("2016-11-19", "yyyy-MM-dd");
Date date2 = DateUtil.parseDate("2016-11-25", "yyyy-MM-dd");
List<Date> weekends = DateUtil.getWeekendBetweenDates(date1, date2);
@@ -37,7 +37,7 @@ public class CitySellCalculator implements Calculator<CitySellResult, CityKey> {
for(RegionBlock region : regions) {
List<RegionBlock> blocks = RegionBlockDao.getInstance().findBlocks(city, region.getName());
for(RegionBlock block : blocks) {
if(!block.getName().contains("南市")){
if(!block.getName().contains("南市")){
continue;
}
calculator.calc(new CityKey(city, region.getName(), block.getName()), weekend);
@@ -91,7 +91,7 @@ public class CitySellCalculator implements Calculator<CitySellResult, CityKey> {
}
});
/****聚类实现方式***/
/****聚类实现方式***/
List<CitySellPoint> samplePoints = new ArrayList<CitySellPoint>();
if(points.size() >= 10) {
samplePoints.addAll(points.subList((int) (points.size() * 0.30), (int) (points.size() * 0.70)));
@@ -14,7 +14,7 @@ import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
/**
* 城市均价处理实现
* 城市均价处理实现
*
* @author duxiaoyu
*
@@ -38,17 +38,17 @@ public class CitySellOperator implements Operator<CityKey, CitySellResult> {
regionStat.setCity(k.getCity());
regionStat.setRegion(null);
regionStat.setBlock(null);
regionStat.setCat("城市");
regionStat.setCat("城市");
} else if (k.isRegion()) {
regionStat.setCity(k.getCity());
regionStat.setRegion(k.getRegion());
regionStat.setBlock(null);
regionStat.setCat("区域");
regionStat.setCat("区域");
} else if (k.isBlock()) {
regionStat.setCity(k.getCity());
regionStat.setRegion(k.getRegion());
regionStat.setBlock(k.getBlock());
regionStat.setCat("板块");
regionStat.setCat("板块");
}
// int steadyValue = keepSteadyValue(k.getCity(), k.getRegion(), k.getBlock(), r.getValue(), r.getCalcDate());
@@ -79,14 +79,14 @@ public class CitySellOperator implements Operator<CityKey, CitySellResult> {
// int consVal = AveragerUtil.makeHashCode(new CityKey(city, region, block), calcDate, FangjiaCalcEnum.SELL);
// double markup = (double) (value - lastStat.getAvgPrice()) / (double) lastStat.getAvgPrice();
//
// // 如果涨跌幅为0,为了保证曲线有起有落,所以为其定制一个很小的涨跌幅
// // 如果涨跌幅为0,为了保证曲线有起有落,所以为其定制一个很小的涨跌幅
// if (Math.abs(markup) == 0) {
// value += value * (double) ((consVal % 60) / 100.0 / 100.0) * ((consVal % 2 == 0) ? 1 : -1);
// } else {
// // 最近一个季度的平均涨跌幅
// // 最近一个季度的平均涨跌幅
// double avgMarkup = regionStatDao.findLatestStatAvgMarkup(city, region, block, calcDate, 13);
// if (!isValidMarkup(markup, avgMarkup)) {
// // 对平均涨跌幅进行最大涨跌150%
// // 对平均涨跌幅进行最大涨跌150%
// double rmarkup = (avgMarkup + avgMarkup * ((double) (consVal % 150) / 100d)) * (markup >= 0 ? 1 : -1);
// value = (int) (lastStat.getAvgPrice() + lastStat.getAvgPrice() * rmarkup);
// }
@@ -120,19 +120,19 @@ public class CitySellOperator implements Operator<CityKey, CitySellResult> {
}
// /**
// * 检查涨跌幅是否正常
// * 检查涨跌幅是否正常
// *
// * @param markup
// * @param avgMarkup
// * @return
// */
// private boolean isValidMarkup(double markup, double avgMarkup) {
// // 每周涨跌1.5%以下属于正常
// // 每周涨跌1.5%以下属于正常
// if (Math.abs(markup) < 0.015) {
// return true;
// }
//
// // 大于平均涨跌幅的0.35倍属于不正常,这样会造成曲线波动很大
// // 大于平均涨跌幅的0.35倍属于不正常,这样会造成曲线波动很大
// if (Math.abs(markup) > (avgMarkup + avgMarkup * 0.35)) {
// return false;
// }
@@ -5,7 +5,7 @@ import java.util.Date;
import com.fangjia.analysis.core.Point;
/**
* 城市、区域、板块的计算的原始样本点
* 城市、区域、板块的计算的原始样本点
*
* @author duxiaoyu
*
@@ -28,7 +28,7 @@ import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
/**
* 城市数据提供者实现
* 城市数据提供者实现
*
* @author duxiaoyu
*
@@ -37,7 +37,7 @@ public class CitySellProvider implements Provider<CityKey, CitySellPoint> {
private static CitySellProvider instance = new CitySellProvider();
private SeaweedDao seaweedDao = SeaweedDao.getInstance();
private DistrictStatDao districtStatDao = DistrictStatDao.getInstance();
//此处时间是为了兼容老版本的均价计算方法
//此处时间是为了兼容老版本的均价计算方法
private static final Date NEW_VERSION_DATE = DateUtil.parseDate("2014-09-13", "yyyy-MM-dd");
public static final String[] DISTRICT_FIELDS = { "city", "region", "block", "name", "estate_type2" };
CitySellProvider() {
@@ -90,9 +90,9 @@ public class CitySellProvider implements Provider<CityKey, CitySellPoint> {
continue;
}
// 如果是新版均价使用可信度
// 如果是新版均价使用可信度
if (calcDate.after(NEW_VERSION_DATE)) {
// 通过自身样板计算出来的小区均价
// 通过自身样板计算出来的小区均价
if (districtStat.getCredit() > Constants.CALC_OWN_BASE_CREDIT) {
CitySellPoint point = new CitySellPoint();
point.setValue(districtStat.getAvgPrice());
@@ -100,7 +100,7 @@ public class CitySellProvider implements Provider<CityKey, CitySellPoint> {
point.setDate(weekend);
ret.add(point);
}
} else {// 如果是在新版本之前的价格计算,则只是用自身样本的小区
} else {// 如果是在新版本之前的价格计算,则只是用自身样本的小区
if (districtStat.getSampleType() != null && "own".equals(districtStat.getSampleType().toLowerCase())) {
CitySellPoint point = new CitySellPoint();
point.setValue(districtStat.getAvgPrice());
@@ -5,16 +5,16 @@ import java.util.Date;
import com.fangjia.analysis.core.Result;
/**
* 城市、区域、板块计算结果
* 城市、区域、板块计算结果
*
* @author duxiaoyu
*
*/
public class CitySellResult implements Result {
private int value; // 运算出的值
private Date calcDate; // 计算日期
private double credit; // 可信度
private double coverage; // 小区覆盖率
private int value; // 运算出的值
private Date calcDate; // 计算日期
private double credit; // 可信度
private double coverage; // 小区覆盖率
public int getValue() {
return value;
@@ -4,20 +4,20 @@ import java.util.HashMap;
import java.util.Map;
/**
* 计算小区均价的常量定义
* 计算小区均价的常量定义
*
* @author xiaoyu
*/
public class Constants {
/**
* 计算小区均价的样本获取量
* 计算小区均价的样本获取量
* DistrictSellConfigProvider.getSampleFetchCount(String city, String region)
*/
public static final int SELL_POINT_FETCH_COUNT = 1000;
/**
* 小区有序队列的区间范围
* 小区有序队列的区间范围
* DistrictSellConfigProvider.getSampleQueueRange(String city, String region)
*/
public static final double MIN_EXTREME_VALUE_PERCENT = 0.35;
@@ -25,37 +25,37 @@ public class Constants {
/**
* 样本的最大最小值
* 样本的最大最小值
* DistrictSellConfigProvider.getSampleValueRange(String city, String region)
*/
public static final double SAMPLE_MIN_VALUE = 1000;
public static final double SAMPLE_MAX_VALUE = 300000;
/**
* 周边小区均价的周边半径(米)
* 周边小区均价的周边半径(米)
* DistrictSellConfigProvider.getAroundRadius
*/
public static final int ARROUND_RADIUS_METERS = 1500;
/**
* 周边小区数量限定数量
* 周边小区数量限定数量
* DistrictSellConfigProvider.getAroundLimit
*/
public static final int AROUND_DISTRICT_LIMIT = 10;
/**
* 强制价格调整系数
* 强制价格调整系数
*/
public static final double HARD_PERCENT = 1.0;
/**
* 主小区影响从小区可信度衰减比例
* 主小区影响从小区可信度衰减比例
*/
public static final double MASTER_INTERVENE_PERCENT = 0.90;
/**
* 样本时间权重设置
* 样本时间权重设置
* DistrictSellConfigProvider.getTimeWeights
*/
public static final Map<Integer, Integer> TIME_WEIGHTS_MAP = new HashMap<Integer, Integer>();
@@ -66,85 +66,85 @@ public class Constants {
}
/*********************************************以上都能进行后台设置************************************************************************************/
/*********************************************以上都能进行后台设置************************************************************************************/
/**
* 小区的二手房成交记录的获取数量
* 小区的二手房成交记录的获取数量
*/
public static final int DEAL_PRICE_FETCH_COUNT = 1000;
/**
* 最多参与第三方价格对比的数量
* 最多参与第三方价格对比的数量
*/
public static final int SELL_VALUE_THIRD_COUNT = 10;
/**
* 价格点和平衡值的最大差比例
* 价格点和平衡值的最大差比例
*/
public static final double MAX_PERCENT_SPOT_BALANCE = 0.03d;
/**
* 与第三方价格的最大差异
* 与第三方价格的最大差异
*/
public static final double MAX_PERCENT_THIRD_DIFF = 0.2d;
/**
* 超过MAX_PERCENT_BALANCE_SPOT的差比部分的紧缩比例
* 超过MAX_PERCENT_BALANCE_SPOT的差比部分的紧缩比例
*/
public static final double ABUT_PERCENT_SPOT_BALANCE = 0.25d;
/**
* 指导价计算出来的基础可信度值
* 指导价计算出来的基础可信度值
*/
public static final double CALC_GUI_BASE_CREDIT = 0.8d;
/**
* 自身样本计算出来的基础可信度值
* 自身样本计算出来的基础可信度值
*/
public static final double CALC_OWN_BASE_CREDIT = 0.6d;
/**
* 第三方价格计算出来的基础可信度值
* 第三方价格计算出来的基础可信度值
*/
public static final double CALC_THIRD_BASE_CREDIT = 0.5d;
/**
* 周边样本计算出来的基础可信度值
* 周边样本计算出来的基础可信度值
*/
public static final double CALC_AROUND_BASE_CREDIT = 0.4d;
/**
* 周边推算的基础可信度值
* 周边推算的基础可信度值
*/
public static final double CALC_DEDUCTION_BASE_CREDIT = 0.3d;
/**
* 通过一个点推导出来的基础可信度值
* 通过一个点推导出来的基础可信度值
*/
public static final double CALC_DERIVATION_BASE_CREDIT = 0.2d;
/**
* 通过第三方价格的调整的影响系数
* 通过第三方价格的调整的影响系数
*/
public static final double CALC_THIRD_REGULATION_FACTOR = 0.1d;
/**
* 按时间影响,每天衰减的可信度(以20年价格进行设计,即:如果一个指导价是20年前添加的,那么可信度+0)
* 按时间影响,每天衰减的可信度(以20年价格进行设计,即:如果一个指导价是20年前添加的,那么可信度+0)
*/
public static final double CREDIT_DECAY_FACTOR = (1.0 - CALC_GUI_BASE_CREDIT) / (365.0 * 20.0);
/**
* 指导价过期天数
* 指导价过期天数
*/
public static final int GUIDING_PRICE_EXPIRATION_DAY = 720;
/**
* 样本换算需要间隔时间
* 样本换算需要间隔时间
*/
public static final int UNCOMFORABLE_SAMPLE_DAY = 360;
/**
* 样本与周边对比的最小相差比例
* 样本与周边对比的最小相差比例
*/
public static final int AROUND_DIFF_MIN_PERCENT = 300;
/**
* 样本与周边对比的最大相差比例
* 样本与周边对比的最大相差比例
*/
public static final int AROUND_DIFF_MAX_PERCENT = 300;
}
@@ -12,7 +12,7 @@ import com.fangjia.mongo.dao.RegionStatDao;
import com.fangjia.mongo.model.RegionStat;
/**
* 小区均价推导算法实现
* 小区均价推导算法实现
*
* @author xiaoyu
*
@@ -31,7 +31,7 @@ public class DistrictAveragerDerivation {
}
/**
* 通过两端的参照点,产生一个指定日期的值
* 通过两端的参照点,产生一个指定日期的值
*
* @param calcDate
* @param k
@@ -57,14 +57,14 @@ public class DistrictAveragerDerivation {
double r = (double) (consVal % 50) / 100.0;
int val = 0;
// 说明整体曲线呈上涨趋势
// 说明整体曲线呈上涨趋势
if (startPoint.getVal().intValue() < endPoint.getVal().intValue()) {
if (consVal % 3 < 2) {
val = startPoint.getVal().intValue() + (int) (ladderValue * (double) (gcw - 1)) + (int) (ladderValue * (1.0 + r));
} else {
val = startPoint.getVal().intValue() + (int) (ladderValue * (double) (gcw - 1)) - (int) (ladderValue * (1.0 - r));
}
} else if (startPoint.getVal().intValue() > endPoint.getVal().intValue()) {// 说明整体曲线呈下落趋势
} else if (startPoint.getVal().intValue() > endPoint.getVal().intValue()) {// 说明整体曲线呈下落趋势
if (consVal % 3 < 2) {
val = startPoint.getVal().intValue() - (int) (ladderValue * (double) (gcw - 1)) - (int) (ladderValue * (1.0 + r));
} else {
@@ -83,7 +83,7 @@ public class DistrictAveragerDerivation {
}
/**
* 通过一个指导价格,推导出指定日期的价格
* 通过一个指导价格,推导出指定日期的价格
*
* @param calcDate
* @param city
@@ -100,7 +100,7 @@ public class DistrictAveragerDerivation {
int ret = -1;
if (region != null) {
// 优先利用区域均价进行推算
// 优先利用区域均价进行推算
ret = doDerivation(city, region, calcDate, guidDate, guidVal);
if (ret <= 0) {
ret = doDerivation(city, null, calcDate, guidDate, guidVal);
@@ -20,7 +20,7 @@ import com.google.common.cache.LoadingCache;
import com.google.common.collect.MapMaker;
/**
* ½»Ò×·¿Ô´ÌṩÕß
* 交易房源提供者
*
* @author dxy
*
@@ -86,7 +86,7 @@ public class DistrictSellAroundCalculator implements Calculator<DistrictSellResu
int capd = 0;
if(regionAvgPrice > 0) {
capd = (int) (regionAvgPrice * 0.005);//以上海为例:均价约为40000,每1KM差距200元
capd = (int) (regionAvgPrice * 0.005);//以上海为例:均价约为40000,每1KM差距200元
}else {
if(cityLevel <= 1) {
capd = 200;
@@ -39,7 +39,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 小区二手房均价计算器
* 小区二手房均价计算器
*
* @author xiaoyu
*
@@ -67,9 +67,9 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
// String[] ids = new String[]{"50c96d5b84aea141aad844f8","56d956756e86ada4910bff59","4eb0cd3a84aee86ec7ca0823","520a6651a2872ee75d8ac0b8","4eb0cd2ce4b0bbc4e450861b","50de9542e4b0027af7574fb1","520ae7b9a2872e3410ff97ac","53460c490e5b70ea9b35f646","56d95ddb6e86ada4910c073e","538309a77c1f5537441123fe","50c7015384aebc1f10a243e7"};
String[] ids = new String[]{"4eb0cd2ce4b0bbc4e450861b"};
String city = "上海";
String region = "虹口";
String name = "商检公寓";
String city = "上海";
String region = "虹口";
String name = "商检公寓";
DBObject q = new BasicDBObject();
// q.put("_id", new BasicDBObject("$in", Arrays.asList(ids)));
q.put("city", city);
@@ -96,17 +96,17 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
public DistrictSellResult calc(DistrictKey k, Date calcDate) throws CalcException, FetchException {
DistrictSellResult res = null;
DistrictKey masterKey = findMasterDistrict(k);
//如果存在主名,说明该小区是一个分期名称
//如果存在主名,说明该小区是一个分期名称
ThreadLocalContainer.getInstance().road(0);
if(masterKey != null && k.getEstateTypeEnum().equals(masterKey.getEstateTypeEnum())) {
//物业类型相同的情况下,认为是分期的小区
//物业类型相同的情况下,认为是分期的小区
res = calcByMasterKey(k, masterKey, calcDate);
ThreadLocalContainer.getInstance().road(1);
}else {
// 采用自身样本
// 采用自身样本
ThreadLocalContainer.getInstance().road(2);
DistrictSellResult ownRes = calcByOwn(k, calcDate);
// 采用指导价
// 采用指导价
DistrictSellResult guiRes = calcByGuiding(k, calcDate);
if(guiRes != null) {
List<String> dates = new ArrayList<String>(guiRes.getGuidingMap().keySet());
@@ -127,8 +127,8 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
ThreadLocalContainer.getInstance().road(23);
/**
* <pre>
* 以最近一年只有(0.010*SELL_POINT_FETCH_COUNT)的自身房源计算的最低质量得分,作为借助于第三方的依据(一年的房源质量得分打7折)
* (等价于一个小区有10套房源,且距今全部为360天,如果房源得分低于这个值,那么会作为第三方价格介入的依据)
* 以最近一年只有(0.010*SELL_POINT_FETCH_COUNT)的自身房源计算的最低质量得分,作为借助于第三方的依据(一年的房源质量得分打7折)
* (等价于一个小区有10套房源,且距今全部为360天,如果房源得分低于这个值,那么会作为第三方价格介入的依据)
* </pre>
*/
double qualityMinMeddleScore = (0.1d / Constants.SELL_POINT_FETCH_COUNT) * (Constants.SELL_POINT_FETCH_COUNT * 0.010d) * 0.7d;
@@ -150,25 +150,25 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
// 采用周边样本
// 采用周边样本
if (res == null) {
ThreadLocalContainer.getInstance().road(26);
res = calcByAround(k, calcDate);
}
// 采用第三方价格
// 采用第三方价格
if (res == null) {
ThreadLocalContainer.getInstance().road(27);
res = calcByThird(k, calcDate);
}
// 采用交易价格
// 采用交易价格
if (res == null) {
ThreadLocalContainer.getInstance().road(28);
res = calcByDealPrice(k, calcDate);
}
// // 采用周边推算
// // 采用周边推算
// if (res == null) {
// res = calcByDistance(k, calcDate);
// }
@@ -187,7 +187,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
return null;
}
//3线以下的城市才通过这样的方式计算
//3线以下的城市才通过这样的方式计算
int supprice = regionStatService.findRegionStat(k.getCity(), k.getRegion(), calcDate);
if(supprice <= 0) {
supprice = regionStatService.findRegionStat(k.getCity(), calcDate);
@@ -211,10 +211,10 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
return null;
}
/**
* 通过主名进行分期小区的价格计算
* 通过主名进行分期小区的价格计算
*
* @param thisKey 分期小区名
* @param masterKey 主小区名
* @param thisKey 分期小区名
* @param masterKey 主小区名
* @param calcDate
* @return
* @throws CalcException
@@ -226,25 +226,25 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
return res;
}
//主小区名计算的结果
//主小区名计算的结果
DistrictSellResult masRes = calcByGuiding(masterKey, calcDate);
if (masRes == null) {
masRes = calcByOwn(masterKey, calcDate);
}
//分期小区名计算的结果
//分期小区名计算的结果
DistrictSellResult subRes = calcByGuiding(thisKey, calcDate);
if (subRes == null) {
subRes = calcByOwn(thisKey, calcDate);
}
//主小区影响从小区可信度衰减比例
//主小区影响从小区可信度衰减比例
double masterIntervenePercent = districtSellConfigProvider.getMasterIntervenePercent(thisKey.getCity(), thisKey.getRegion(), thisKey.getName());
if(subRes != null && masRes != null) {
//分期小区自己计算的可信度,与主名计算的可信度差距不大,优先使用分期自己的结果
//分期小区自己计算的可信度,与主名计算的可信度差距不大,优先使用分期自己的结果
if(subRes.getCredit() > masRes.getCredit() * masterIntervenePercent) {
res = subRes;
}else {//使用主名计算的价格,需要降低可信度
}else {//使用主名计算的价格,需要降低可信度
masRes.setValue(generateSubPriceByMasResult(thisKey, masRes));
masRes.setCredit((int)(masRes.getCredit() * masterIntervenePercent * 100000.0) / 100000.0);
res = masRes;
@@ -260,12 +260,12 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
return res;
}
public static final Pattern SUB_PATT = Pattern.compile(".+([一|二|三|四|五|六|七|八|九])期$");
public static final Pattern SUB_PATT = Pattern.compile(".+([一|二|三|四|五|六|七|八|九])期$");
private int generateSubPriceByMasResult(DistrictKey subKey, DistrictSellResult masRes) {
Matcher matcher = SUB_PATT.matcher(subKey.getName());
double p = 1.0;
if(matcher.matches()) {
//按每一期价格比上一期大0.5%为计算基础
//按每一期价格比上一期大0.5%为计算基础
double r = (double)(AveragerUtil.makeHashCode(subKey, masRes.getCalcDate(), FangjiaCalcEnum.SELL) % 500) / 1000.0;
p += (1.0 + (DataUtil.convertToNumber(matcher.group(1)) - 1) * 0.50 + r) / 100.0;
}
@@ -274,7 +274,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 确认这个小区是否是分期的小区
* 确认这个小区是否是分期的小区
*
* @param k
* @return null=false
@@ -284,7 +284,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
if(object != null) {
ThreadLocalContainer.getInstance().put("did2", object.getId());
}
//是一个小区的分期名称
//是一个小区的分期名称
if(object != null && StringUtils.isNotBlank(object.getMasterDistrictName()) && !object.getMasterDistrictName().equals(k.getName())) {
Seaweed masterObject = districtService.findByPrimaryKey(k.getCity(), k.getRegion(), object.getMasterDistrictName());
if(masterObject != null) {
@@ -295,7 +295,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 自身样本计算
* 自身样本计算
*
* @param k
* @param calcDate
@@ -310,7 +310,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
LOGGER.debug("sellPoints size:" + sellPoints.size());
ThreadLocalContainer.getInstance().road(6);
//判断是否达到最低样本要求
//判断是否达到最低样本要求
int ownTypeLimit = districtSellConfigProvider.getOwnTypeLimit(k.getCity(), k.getRegion(), k.getName());
if(sellPoints.size() < ownTypeLimit) {
return null;
@@ -323,33 +323,33 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
int fetchCount = DistrictSellConfigProvider.getInstance().getSampleFetchCount(k.getCity(), k.getRegion(), k.getName());
/**
* 可信度=基础值+数量得分+质量得分+第三方影响得分
* 可信度=基础值+数量得分+质量得分+第三方影响得分
*/
ThreadLocalContainer.getInstance().road(7);
// 数量得分
// 数量得分
double amountCredit = ownSampleAmountCredit(sellPoints, fetchCount);
// 质量得分
// 质量得分
double qualityCredit = ownSampleQualityCredit(sellPoints, calcDate, fetchCount);
// 第三方影响分
// 第三方影响分
double thirdFactor = 0;
DistrictSellResult res = new DistrictSellResult();
res.setCalcDate(calcDate);
Integer valueCluType = districtSellConfigProvider.getValueCluType(k.getCity(), k.getRegion(), k.getName());
ThreadLocalContainer.getInstance().put("valueCluType", valueCluType);
if(valueCluType != null && valueCluType == 1){//类簇的中位数
if(valueCluType != null && valueCluType == 1){//类簇的中位数
res.setValue(cluster.getMedian());
}else if(valueCluType != null && valueCluType == 2){//类簇的最大值
}else if(valueCluType != null && valueCluType == 2){//类簇的最大值
res.setValue(cluster.getMaxValue());
}else if(valueCluType != null && valueCluType == 3){//类簇的最小值
}else if(valueCluType != null && valueCluType == 3){//类簇的最小值
res.setValue(cluster.getMinValue());
}else {//默认值
}else {//默认值
res.setValue(cluster.getValue());
}
res.setOwnSampleCount(cluster.getSampleSize());
res.setCredit(Constants.CALC_OWN_BASE_CREDIT + (amountCredit + qualityCredit + thirdFactor));
res.setCredit(((int) (res.getCredit() * 100000.0)) / 100000.0);// 保留5位小数
res.setCredit(((int) (res.getCredit() * 100000.0)) / 100000.0);// 保留5位小数
res.setValueType(ValueTypeEnum.OWN);
res.setSampleDetailMap(getSampleDetailMap(sellPoints, calcDate));
res.setAmountCredit(amountCredit);
@@ -366,7 +366,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 住宅样本详细分布情况统计
* 住宅样本详细分布情况统计
* @param points
* @param calcDate
* @return
@@ -401,7 +401,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 对样本进行处理
* 对样本进行处理
*
* @param points
* @return
@@ -413,7 +413,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
List<E> newPoints = new ArrayList<E>();
//根据网站进行系数涨跌
//根据网站进行系数涨跌
for (E dsp : points) {
if (dsp instanceof DistrictSellPoint) {
try {
@@ -434,7 +434,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
List<E> clonePoints = new ArrayList<E>();
//网站权重设置
//网站权重设置
for (E dsp : newPoints) {
if(dsp instanceof DistrictSellPoint) {
String site = DataUtil.urlToSiteName(((DistrictSellPoint)dsp).getUrl());
@@ -456,7 +456,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
//如果该城市对区域不敏感,那么区域相同的房源权重加权
//如果该城市对区域不敏感,那么区域相同的房源权重加权
if(!districtSellConfigProvider.isCaseRegion(k.getCity(), k.getRegion(), k.getName())) {
ThreadLocalContainer.getInstance().put("caseRegion2", false);
List<E> sames = new ArrayList<E>();
@@ -469,7 +469,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
//至少让相同区域的房源加权之后,占据总数据量的25%
//至少让相同区域的房源加权之后,占据总数据量的25%
double rt = Math.ceil((double)clonePoints.size() / 4.0 / (double)sames.size());
rt = (rt < 1.0 ? 1 : rt);
for (E p : sames) {
@@ -488,10 +488,10 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
List<Integer> ret = new ArrayList<Integer>();
int cityLevel = serverAreaDao.getCityLevel(k.getCity());
//最近一个月城市和区域的平均均价
//最近一个月城市和区域的平均均价
int cityBalanceValue = regionStatService.findRegionStatBalanceValue(k.getCity(), null, null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
int regionBalanceValue = regionStatService.findRegionStatBalanceValue(k.getCity(), k.getRegion(), null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
//样本需要通过城市均价进行涨跌的天数限制
//样本需要通过城市均价进行涨跌的天数限制
int uncomforableSampleDay = districtSellConfigProvider.getUncomforableSampleDay(k.getCity(), k.getRegion(), k.getName());
LOGGER.error("UNCOMFORABLE_SAMPLE_DAY:" + uncomforableSampleDay);
ThreadLocalContainer.getInstance().put("cityBalanceValue", cityBalanceValue);
@@ -499,15 +499,15 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
ThreadLocalContainer.getInstance().put("uncomforableSampleDay", uncomforableSampleDay);
ThreadLocalContainer.getInstance().put("timeWeight", districtSellConfigProvider.getTimeWeights(k.getCity(), k.getRegion(), k.getName()));
//时间权重设置
//时间权重设置
for (E dsp : clonePoints) {
int val = dsp.getValue();
int orgVal = val;
// 一年之外的样本按照城市均价进行涨跌
// 一年之外的样本按照城市均价进行涨跌
if(Math.abs(calcDate.getTime() - dsp.getDate().getTime()) > uncomforableSampleDay * DAY_MILLS) {
double yearMarkup = getYearMarkup(k.getCity(), k.getRegion(), dsp.getDate(), calcDate);
val = (int) (dsp.getValue() + dsp.getValue() * yearMarkup);
LOGGER.debug("涨跌幅:{}->{}", new int[]{orgVal, val});
LOGGER.debug("涨跌幅:{}->{}", new int[]{orgVal, val});
}
val = (int)(val * hardPercent);
@@ -515,7 +515,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
if (cityBalanceValue > 0 && (val < cityBalanceValue / 10 || val > cityBalanceValue * 10)) {
continue;
}
}else if(cityLevel == 2) {//二线城市
}else if(cityLevel == 2) {//二线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 7.5 || val > cityBalanceValue * 7.5)) {
continue;
}
@@ -523,21 +523,21 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
continue;
}
}else if(cityLevel == 3) {//三线城市
}else if(cityLevel == 3) {//三线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 6 || val > cityBalanceValue * 6)) {
continue;
}
if (regionBalanceValue > 0 && (val < regionBalanceValue / 4 || val > regionBalanceValue * 4)) {
continue;
}
}else if(cityLevel == 4) {//四线城市
}else if(cityLevel == 4) {//四线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 4 || val > cityBalanceValue * 4)) {
continue;
}
if (regionBalanceValue > 0 && (val < regionBalanceValue / 3 || val > regionBalanceValue * 3)) {
continue;
}
}else if(cityLevel == 5) {//五线城市
}else if(cityLevel == 5) {//五线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 3.5 || val > cityBalanceValue * 3.5)) {
continue;
}
@@ -546,17 +546,17 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
ret.add(val);
// 对于比较新的样本进行复制,以达到越新的样本影响权重越高的目的
// 对于比较新的样本进行复制,以达到越新的样本影响权重越高的目的
int weightValue = districtSellConfigProvider.getTimeWeights(k.getCity(), k.getRegion(), k.getName(), Math.abs(calcDate.getTime() - dsp.getDate().getTime()));
if(weightValue > 0) {
int randCode = AveragerUtil.makeHashCode(k, dsp.getDate(), FangjiaCalcEnum.SELL);
for (int i = 0; i < weightValue; i++) {
ret.add(val + (randCode % (i + 6)));//随机产生一个和原始值差不多的数字
ret.add(val + (randCode % (i + 6)));//随机产生一个和原始值差不多的数字
}
}
}
// 使均值往一端偏移
// 使均值往一端偏移
if (ret.size() > 10) {
Collections.sort(ret);
AbstractConfigProvider.Range sampleQueueRange = districtSellConfigProvider.getSampleQueueRange(k.getCity(), k.getRegion(), k.getName());
@@ -584,7 +584,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
/**
* 通过指导价计算
* 通过指导价计算
*
* @param k
* @param calcDate
@@ -612,7 +612,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
Map<String, Integer> guidingMap = new HashMap<String, Integer>();
for (GuidingPrice gp : guidingPrices) {
long diffTime = Math.abs(gp.getGuidingDate().getTime() - calcDate.getTime());
//根据系数检查该指导价是否可以使用
//根据系数检查该指导价是否可以使用
if(diffTime < guidingPriceExpirDay * DAY_MILLS) {
guidingMap.put(DateUtil.formatToTightYYYYMMDD(gp.getGuidingDate()), gp.getGuidingValue());
}
@@ -630,14 +630,14 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
res.setCredit(1.0);
} else {
if (calcDate.after(guidingPrices.get(0).getGuidingDate())) {
// 计算日期大于最新的指导价
// 计算日期大于最新的指导价
CommonPoint point = new CommonPoint(guidingPrices.get(0).getGuidingValue(), guidingPrices.get(0).getGuidingDate());
res.setValue(derivation.derivationPointByPoint(calcDate, city, region, point));
res.setCredit(Constants.CALC_GUI_BASE_CREDIT
+ ((1.0 - Constants.CALC_GUI_BASE_CREDIT) - (Constants.CREDIT_DECAY_FACTOR * Math.abs(DateUtil
.getAfterDays(guidingPrices.get(0).getGuidingDate(), calcDate)))));
} else if (calcDate.before(guidingPrices.get(guidingPrices.size() - 1).getGuidingDate())) {
// 计算日期小于最老的指导价
// 计算日期小于最老的指导价
CommonPoint point = new CommonPoint(guidingPrices.get(guidingPrices.size() - 1).getGuidingValue(), guidingPrices
.get(guidingPrices.size() - 1).getGuidingDate());
@@ -646,7 +646,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
+ ((1.0 - Constants.CALC_GUI_BASE_CREDIT) - (Constants.CREDIT_DECAY_FACTOR * Math.abs(DateUtil
.getAfterDays(guidingPrices.get(guidingPrices.size() - 1).getGuidingDate(), calcDate)))));
} else {
// 计算日期在两个指导价之间
// 计算日期在两个指导价之间
GuidingPrice[] gps = findGuidingPriceRange(guidingPrices, calcDate);
if (gps != null) {
CommonPoint leftPoint = new CommonPoint(gps[0].getGuidingValue(), gps[0].getCreationDate());
@@ -669,11 +669,11 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
// int cityBalanceValue = regionStatService.findRegionStatBalanceValue(k.getCity(), null, null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
// int regionBalanceValue = regionStatService.findRegionStatBalanceValue(k.getCity(), k.getRegion(), null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
// int districtBalanceValue = districtStatService.findAroundDistrictStat(k, 500, calcDate);
// //和周边均价进行对比,因为是指导价和周边价格差距在2倍,就认为是异常数据
// //和周边均价进行对比,因为是指导价和周边价格差距在2倍,就认为是异常数据
// if (districtBalanceValue > 0 && (avgPrice < districtBalanceValue / 2 || avgPrice > districtBalanceValue * 2)) {
// return null;
// }
//根据不同的城市级别进行数据过滤
//根据不同的城市级别进行数据过滤
// if(cityLevel <= 1) {
// if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 12 || avgPrice > cityBalanceValue * 12)) {
// return null;
@@ -681,28 +681,28 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
// if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 8 || avgPrice > regionBalanceValue * 8)) {
// return null;
// }
// }else if(cityLevel == 2) {//二线城市
// }else if(cityLevel == 2) {//二线城市
// if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 7.5 || avgPrice > cityBalanceValue * 7.5)) {
// return null;
// }
// if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 5.5 || avgPrice > regionBalanceValue * 5.5)) {
// return null;
// }
// }else if(cityLevel == 3) {//三线城市
// }else if(cityLevel == 3) {//三线城市
// if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 6 || avgPrice > cityBalanceValue * 6)) {
// return null;
// }
// if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 4 || avgPrice > regionBalanceValue * 4)) {
// return null;
// }
// }else if(cityLevel == 4) {//四线城市
// }else if(cityLevel == 4) {//四线城市
// if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 4 || avgPrice > cityBalanceValue * 4)) {
// return null;
// }
// if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 3 || avgPrice > regionBalanceValue * 3)) {
// return null;
// }
// }else if(cityLevel == 5) {//五线城市
// }else if(cityLevel == 5) {//五线城市
// if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 3.5 || avgPrice > cityBalanceValue * 3.5)) {
// return null;
// }
@@ -717,28 +717,28 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 按照交易价进行计算
* 按照交易价进行计算
*
* @param k
* @param calcDate
* @return
*/
private DistrictSellResult calcByDealPrice(DistrictKey k, Date calcDate) {
// 交易数据
// 交易数据
List<DistrictDealPoint> dealPoints = dealProvider.fetch(k, calcDate);
// 交易数据的计算值
// 交易数据的计算值
int dealValue = 0;
// 超过3个交易数据,则进行交易数据聚类
// 超过3个交易数据,则进行交易数据聚类
if (dealPoints.size() > 3) {
for (DistrictDealPoint ddp : dealPoints) {
// 如果是交易中心的价格,上浮5%
// 如果是交易中心的价格,上浮5%
if (ddp.getSource() != null && ddp.getSource().indexOf(SourceEnum.JIAOYIZHONGXIN.getCategory()) > -1) {
ddp.setValue((int) (ddp.getValue() * 1.05));
}
}
// 预处理交易数据
// 预处理交易数据
List<Integer> points = processingPoint(k, calcDate, dealPoints);
Cluster cluster = DataCluster.cluster(points);
@@ -761,14 +761,14 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 第三方价格计算 (包括网络均价,成交价)
* 第三方价格计算 (包括网络均价,成交价)
*
* @param k
* @param calcDate
* @return
*/
private DistrictSellResult calcByThird(DistrictKey k, Date calcDate) {
// 第三方价格数据
// 第三方价格数据
List<Map<String, Object>> thirdpartDetails = averageStatisticsDao.findThirdpartsAveragers(k.getCity(), k.getRegion(),
k.getName(), "district", calcDate);
List<Integer> orgThirdPoints = getThridpartPoint(thirdpartDetails);
@@ -782,7 +782,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
List<Integer> thirdPoints = new ArrayList<Integer>();
for(Integer p : orgThirdPoints) {
//根据不同的城市级别进行数据过滤
//根据不同的城市级别进行数据过滤
if (cityLevel <= 1) {
if (cityBalanceValue > 0 && (p < cityBalanceValue / 10 || p > cityBalanceValue * 10)) {
continue;
@@ -790,28 +790,28 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
if (regionBalanceValue > 0 && (p < regionBalanceValue / 7 || p > regionBalanceValue * 7)) {
continue;
}
} else if (cityLevel == 2) {//二线城市
} else if (cityLevel == 2) {//二线城市
if (cityBalanceValue > 0 && (p < cityBalanceValue / 7.5 || p > cityBalanceValue * 7.5)) {
continue;
}
if (regionBalanceValue > 0 && (p < regionBalanceValue / 5.5 || p > regionBalanceValue * 5.5)) {
continue;
}
} else if (cityLevel == 3) {//三线城市
} else if (cityLevel == 3) {//三线城市
if (cityBalanceValue > 0 && (p < cityBalanceValue / 6 || p > cityBalanceValue * 6)) {
continue;
}
if (regionBalanceValue > 0 && (p < regionBalanceValue / 4 || p > regionBalanceValue * 4)) {
continue;
}
} else if (cityLevel == 4) {//四线城市
} else if (cityLevel == 4) {//四线城市
if (cityBalanceValue > 0 && (p < cityBalanceValue / 4 || p > cityBalanceValue * 4)) {
continue;
}
if (regionBalanceValue > 0 && (p < regionBalanceValue / 3 || p > regionBalanceValue * 3)) {
continue;
}
} else if (cityLevel == 5) {//五线城市
} else if (cityLevel == 5) {//五线城市
if (cityBalanceValue > 0 && (p < cityBalanceValue / 3.5 || p > cityBalanceValue * 3.5)) {
continue;
}
@@ -827,7 +827,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
return null;
}
// 第三方的数据的计算值
// 第三方的数据的计算值
int thirdValue = getCluvalue(thirdPoints, Constants.MAX_PERCENT_THIRD_DIFF);
if (thirdValue <= 0) {
return null;
@@ -918,7 +918,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
// }
/**
* 周边样本计算
* 周边样本计算
*
* @param k
* @param calcDate
@@ -945,7 +945,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
DistrictKey akey = new DistrictKey(district.getCity(), district.getRegion(), district.getName(),
EstateTypeEnum.parse(district.getEstateType2()));
DistrictSellResult res = null;
// 采用指导价
// 采用指导价
if (guidingPriceDao.isExistGuidingPrice(district.getCity(), district.getRegion(), district.getName(), CATEGORY,
district.getEstateType2())) {
res = calcByGuiding(akey, calcDate);
@@ -956,7 +956,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
// 采用自身样本
// 采用自身样本
if (res == null) {
res = calcByOwn(akey, calcDate);
if (res != null && res.getValueType().equals(ValueTypeEnum.OWN)) {
@@ -987,7 +987,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 第三方价格计算可信度算法(<0.6)
* 第三方价格计算可信度算法(<0.6)
*
* @param thirdPoints
* @param calcDate
@@ -998,20 +998,20 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 交易数据可信度算法(<0.6)
* 交易数据可信度算法(<0.6)
*
* @param dealPoints
* @param calcDate
* @return
*/
private double calcDealPriceCredit(List<DistrictDealPoint> dealPoints, Date calcDate) {
double c1 = ownSampleAmountCredit(dealPoints, Constants.SELL_POINT_FETCH_COUNT) / 2.0;// 最高分0.05
double c2 = ownSampleQualityCredit(dealPoints, calcDate, Constants.SELL_POINT_FETCH_COUNT) / 2.0;// 最高分0.05
double c1 = ownSampleAmountCredit(dealPoints, Constants.SELL_POINT_FETCH_COUNT) / 2.0;// 最高分0.05
double c2 = ownSampleQualityCredit(dealPoints, calcDate, Constants.SELL_POINT_FETCH_COUNT) / 2.0;// 最高分0.05
return Constants.CALC_THIRD_BASE_CREDIT + (c1 + c2);
}
/**
* 数量得分(最高得分0.1)
* 数量得分(最高得分0.1)
*
* @param points
* @return
@@ -1020,14 +1020,14 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
if (points.size() == 0) {
return 0;
}
// 每100个样本=0.01
// 每100个样本=0.01
double c1 = 0.1 * ((double) points.size()/sellPointFetchCount);
c1 = (c1 > 0.1 ? 0.1 : c1);
return c1;
}
/**
* 质量得分(最高得分0.1)
* 质量得分(最高得分0.1)
*
* @param points
* @return
@@ -1043,21 +1043,21 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
for (E p : points) {
Date d = p.getDate();
long diff = calcDate.getTime() - d.getTime();
if (diff <= 30 * 24 * 3600 * 1000L) {// 一个月内
if (diff <= 30 * 24 * 3600 * 1000L) {// 一个月内
c2 = c2 + perc * 1.00d;
} else if (diff <= 60 * 24 * 3600 * 1000L) {// 两个月内
} else if (diff <= 60 * 24 * 3600 * 1000L) {// 两个月内
c2 = c2 + perc * 0.90d;
} else if (diff <= 90 * 24 * 3600 * 1000L) {// 三个月内
} else if (diff <= 90 * 24 * 3600 * 1000L) {// 三个月内
c2 = c2 + perc * 0.8d;
} else if (diff <= 180 * 24 * 3600 * 1000L) {// 半年内
} else if (diff <= 180 * 24 * 3600 * 1000L) {// 半年内
c2 = c2 + perc * 0.7d;
} else if (diff <= 365 * 24 * 3600 * 1000L) {// 一年内
} else if (diff <= 365 * 24 * 3600 * 1000L) {// 一年内
c2 = c2 + perc * 0.60d;
} else if (diff <= 540 * 24 * 3600 * 1000L) {// 一年半内
} else if (diff <= 540 * 24 * 3600 * 1000L) {// 一年半内
c2 = c2 + perc * 0.50d;
} else if (diff <= 720 * 24 * 3600 * 1000L) {// 两年内
} else if (diff <= 720 * 24 * 3600 * 1000L) {// 两年内
c2 = c2 + perc * 0.40d;
} else {// 超过两年
} else {// 超过两年
c2 = c2 + perc * 0.10d;
}
}
@@ -1066,7 +1066,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 通过一个日期,获得相邻的两个指导价
* 通过一个日期,获得相邻的两个指导价
*
* @param guidingPrices
* @param calcDate
@@ -1107,30 +1107,30 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 通过第三方价格修正计算值
* 通过第三方价格修正计算值
*
* @param k
* 小区key
* 小区key
* @param calcDate
* 计算日期
* 计算日期
* @param value
* 计算值
* 计算值
* @param thirdPoints
* 第三方参照值
* 第三方参照值
* @param amountCredit
* 数量得分
* 数量得分
* @param qualityCredit
* 质量得分
* @return null说明没有进行任何校正
* 质量得分
* @return null说明没有进行任何校正
*/
private Revisor valueRevisionByThird(DistrictKey k, Date calcDate, int value, List<Integer> thirdPoints, double amountCredit,
double qualityCredit) {
if (thirdPoints == null || thirdPoints.size() == 0) {// 如果没有第三方,则忽略这次投票
if (thirdPoints == null || thirdPoints.size() == 0) {// 如果没有第三方,则忽略这次投票
return null;
}
List<Integer> ayes = new ArrayList<Integer>(); // 支持者
List<Integer> nays = new ArrayList<Integer>(); // 反对者
List<Integer> ayes = new ArrayList<Integer>(); // 支持者
List<Integer> nays = new ArrayList<Integer>(); // 反对者
for (Integer val : thirdPoints) {
if (Math.abs((double) (value - val) / (double) value) < Constants.MAX_PERCENT_THIRD_DIFF) {
@@ -1140,13 +1140,13 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
boolean isElected = false; // 是否获得了第三方的支持
double percOfAyes = (double) ayes.size() / (double) thirdPoints.size(); // 支持率
boolean isElected = false; // 是否获得了第三方的支持
double percOfAyes = (double) ayes.size() / (double) thirdPoints.size(); // 支持率
/**
* <pre>
* 以最近一年只有(0.05*SELL_POINT_FETCH_COUNT)的自身房源计算的最低质量得分,作为借助于第三方的依据(一年的房源质量得分打7折)
* (等价于一个小区有5套房源,且距今全部为360天,如果房源得分低于这个值,那么会作为第三方价格介入的依据)
* 以最近一年只有(0.05*SELL_POINT_FETCH_COUNT)的自身房源计算的最低质量得分,作为借助于第三方的依据(一年的房源质量得分打7折)
* (等价于一个小区有5套房源,且距今全部为360天,如果房源得分低于这个值,那么会作为第三方价格介入的依据)
* </pre>
*/
double meddleScore = (0.1d / Constants.SELL_POINT_FETCH_COUNT) * (Constants.SELL_POINT_FETCH_COUNT * 0.005d) * 0.7d;
@@ -1154,56 +1154,56 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
int nval = 0;
if (thirdPoints.size() == 1) {// 如果只有1张选票
if (percOfAyes >= 1.0) {// 获得了第三方价格的支持
if (thirdPoints.size() == 1) {// 如果只有1张选票
if (percOfAyes >= 1.0) {// 获得了第三方价格的支持
isElected = true;
}
double perc = (double) (100 + hashCode % 100) / 100.0 / 100.0; // 涨跌2.00%-5.00%
double perc = (double) (100 + hashCode % 100) / 100.0 / 100.0; // 涨跌2.00%-5.00%
if (thirdPoints.get(0) > value) {
nval = (int) (value + value * perc);
} else {
nval = (int) (value - value * perc);
}
} else if (thirdPoints.size() == 2 && percOfAyes <= 0) {// 只有2张,并且这2张票全部丢失
if (qualityCredit < meddleScore) {// 质量得分是否低于第三方介入最低标准
} else if (thirdPoints.size() == 2 && percOfAyes <= 0) {// 只有2张,并且这2张票全部丢失
if (qualityCredit < meddleScore) {// 质量得分是否低于第三方介入最低标准
double dp = (double) (nays.get(0) - nays.get(1)) / (double) nays.get(0);
if (Math.abs(dp) <= Constants.MAX_PERCENT_THIRD_DIFF) {// 判断这两票的意见是否一致
nval = (nays.get(0) + nays.get(1)) / 2; // 意见基本一致的话,直接采用这两个价格的平均值
if (Math.abs(dp) <= Constants.MAX_PERCENT_THIRD_DIFF) {// 判断这两票的意见是否一致
nval = (nays.get(0) + nays.get(1)) / 2; // 意见基本一致的话,直接采用这两个价格的平均值
}
}
} else if (thirdPoints.size() == 2 && percOfAyes >= 1.0) {// 只有2张,并且这2张票全部支持
isElected = true; // 获得了第三方价格的支持
double perc = (double) (200 + hashCode % 300) / 100.0 / 100.0; // 涨跌2.00%-5.00%
if (isSmallest(ayes, value)) {// 小于所有支持者,适当上调
} else if (thirdPoints.size() == 2 && percOfAyes >= 1.0) {// 只有2张,并且这2张票全部支持
isElected = true; // 获得了第三方价格的支持
double perc = (double) (200 + hashCode % 300) / 100.0 / 100.0; // 涨跌2.00%-5.00%
if (isSmallest(ayes, value)) {// 小于所有支持者,适当上调
nval = (int) (value + value * perc);
} else if (isBiggest(ayes, value)) {// 大于所有支持者,适当下调
} else if (isBiggest(ayes, value)) {// 大于所有支持者,适当下调
nval = (int) (value - value * perc);
}
} else if (thirdPoints.size() == 3) {
if (percOfAyes >= 0.33) {//如果3个中有1个支持,那么就会大于33%
if (percOfAyes >= 0.33) {//如果3个中有1个支持,那么就会大于33%
} else {
if (qualityCredit < meddleScore) {// 质量得分是否低于第三方介入最低标准
if (pointSimilarityScorer(nays) > 0.7) {// 判断这些反对者,是否意见保持一致
if (qualityCredit < meddleScore) {// 质量得分是否低于第三方介入最低标准
if (pointSimilarityScorer(nays) > 0.7) {// 判断这些反对者,是否意见保持一致
nval = getMeanvalue(nays, true);
}
}
}
} else {// 总票数>=3票
if (percOfAyes <= 0.1) {// 得票率太低<=0.1,说明绝大部分第三方价格与计算值差异较大
} else {// 总票数>=3票
if (percOfAyes <= 0.1) {// 得票率太低<=0.1,说明绝大部分第三方价格与计算值差异较大
nval = getMeanvalue(thirdPoints, true);
} else if (percOfAyes >= 0.5) {// 得票率过半>=0.5,则信任计算值,仅仅做必要的微调
isElected = true; // 获得了第三方价格的支持
double perc = (double) (200 + hashCode % 300) / 100.0 / 100.0; // 涨跌2.00%-5.00%
if (isSmallest(ayes, value)) {// 小于所有支持者,适当上调
} else if (percOfAyes >= 0.5) {// 得票率过半>=0.5,则信任计算值,仅仅做必要的微调
isElected = true; // 获得了第三方价格的支持
double perc = (double) (200 + hashCode % 300) / 100.0 / 100.0; // 涨跌2.00%-5.00%
if (isSmallest(ayes, value)) {// 小于所有支持者,适当上调
nval = (int) (value + value * perc);
} else if (isBiggest(ayes, value)) {// 大于所有支持者,适当下调
} else if (isBiggest(ayes, value)) {// 大于所有支持者,适当下调
nval = (int) (value - value * perc);
}
} else {// 0.1<得票率<0.5,说明超过半数的第三方价格与计算值差异较大
if (qualityCredit < meddleScore) {// 质量得分是否低于第三方介入最低标准
if (pointSimilarityScorer(nays) > 0.7) {// 判断这些反对者,是否意见保持一致
} else {// 0.1<得票率<0.5,说明超过半数的第三方价格与计算值差异较大
if (qualityCredit < meddleScore) {// 质量得分是否低于第三方介入最低标准
if (pointSimilarityScorer(nays) > 0.7) {// 判断这些反对者,是否意见保持一致
nval = getMeanvalue(nays, true);
}
}
@@ -1221,7 +1221,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 数字近似度打分
* 数字近似度打分
*
* @param list
* @return
@@ -1232,8 +1232,8 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
double mv = getMeanvalue(list, false);
List<Integer> a = new ArrayList<Integer>(); // 支持者
List<Integer> n = new ArrayList<Integer>(); // 反对者
List<Integer> a = new ArrayList<Integer>(); // 支持者
List<Integer> n = new ArrayList<Integer>(); // 反对者
for (Integer val : list) {
if (Math.abs((double) (mv - val) / (double) mv) < Constants.MAX_PERCENT_THIRD_DIFF) {
a.add(val);
@@ -1274,11 +1274,11 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 排除差异较大的数字,获取一个数组的平均值,如果每个数字之间的差异都超过了指定值,就返回-1
* 排除差异较大的数字,获取一个数组的平均值,如果每个数字之间的差异都超过了指定值,就返回-1
*
* @param list
* @param maxDiffPercent
* 数字的最大差异
* 数字的最大差异
* @return
*/
private int getCluvalue(List<Integer> list, double maxDiffPercent) {
@@ -1318,11 +1318,11 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 获取平均值,数据长度超过3,就去除极值
* 获取平均值,数据长度超过3,就去除极值
*
* @param list
* @param isExtremal
* 是否去除极值
* 是否去除极值
* @return
*/
private int getMeanvalue(List<Integer> list, boolean isExtremal) {
@@ -1356,15 +1356,15 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 比较结果实体
* 比较结果实体
*
* @author dxy
*
*/
class VotingResult {
private final List<Integer> alls; // 全部票数
private final List<Integer> ayes; // 赞成票
private final List<Integer> nays; // 反对票
private final List<Integer> alls; // 全部票数
private final List<Integer> ayes; // 赞成票
private final List<Integer> nays; // 反对票
public VotingResult(List<Integer> alls, List<Integer> ayes, List<Integer> nays) {
this.alls = alls;
@@ -1394,14 +1394,14 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
/**
* 影响结果定义
* 影响结果定义
*
* @author dxy
*
*/
class Revisor {
private final int value; // 修正后的值
private final double factor; // 修正后的可信度影响
private final int value; // 修正后的值
private final double factor; // 修正后的可信度影响
public Revisor(int value, double factor) {
this.value = value;
@@ -1425,7 +1425,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
List<DistrictSellPoint> clonePoints = new ArrayList<DistrictSellPoint>();
//网站权重设置
//网站权重设置
for (DistrictSellPoint dsp : points) {
if(dsp instanceof DistrictSellPoint) {
String site = DataUtil.urlToSiteName(((DistrictSellPoint)dsp).getUrl());
@@ -1446,7 +1446,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
//如果该城市对区域不敏感,那么区域相同的房源权重加权
//如果该城市对区域不敏感,那么区域相同的房源权重加权
if(!districtSellConfigProvider.isCaseRegion(k.getCity(), k.getRegion(), k.getName())) {
List<DistrictSellPoint> sames = new ArrayList<DistrictSellPoint>();
for (DistrictSellPoint p : clonePoints) {
@@ -1458,7 +1458,7 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
}
}
//至少让相同区域的房源加权之后,占据总数据量的25%
//至少让相同区域的房源加权之后,占据总数据量的25%
double rt = Math.ceil((double)clonePoints.size() / 4.0 / (double)sames.size());
rt = (rt < 1.0 ? 1 : rt);
for (DistrictSellPoint p : sames) {
@@ -1476,16 +1476,16 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
List<DistrictSellPoint> ret = new ArrayList<DistrictSellPoint>();
int cityLevel = serverAreaDao.getCityLevel(k.getCity());
//最近一个月城市和区域的平均均价
//最近一个月城市和区域的平均均价
int cityBalanceValue = regionStatService.findRegionStatBalanceValue(k.getCity(), null, null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
int regionBalanceValue = regionStatService.findRegionStatBalanceValue(k.getCity(), k.getRegion(), null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
//样本需要通过城市均价进行涨跌的天数限制
//样本需要通过城市均价进行涨跌的天数限制
int uncomforableSampleDay = districtSellConfigProvider.getUncomforableSampleDay(k.getCity(), k.getRegion(), k.getName());
LOGGER.error("UNCOMFORABLE_SAMPLE_DAY:" + uncomforableSampleDay);
//时间权重设置
//时间权重设置
for (DistrictSellPoint dsp : clonePoints) {
int val = dsp.getValue();
// 一年之外的样本按照城市均价进行涨跌
// 一年之外的样本按照城市均价进行涨跌
if(Math.abs(calcDate.getTime() - dsp.getDate().getTime()) > uncomforableSampleDay * DAY_MILLS) {
double yearMarkup = getYearMarkup(k.getCity(),k.getRegion(), dsp.getDate(), calcDate);
val = (int) (dsp.getValue() + dsp.getValue() * yearMarkup);
@@ -1498,28 +1498,28 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
if (cityBalanceValue > 0 && (val < cityBalanceValue / 10 || val > cityBalanceValue * 10)) {
continue;
}
}else if(cityLevel == 2) {//二线城市
}else if(cityLevel == 2) {//二线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 7.5 || val > cityBalanceValue * 7.5)) {
continue;
}
if (regionBalanceValue > 0 && (val < regionBalanceValue / 5.5 || val > regionBalanceValue * 5.5)) {
continue;
}
}else if(cityLevel == 3) {//三线城市
}else if(cityLevel == 3) {//三线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 6 || val > cityBalanceValue * 6)) {
continue;
}
if (regionBalanceValue > 0 && (val < regionBalanceValue / 4 || val > regionBalanceValue * 4)) {
continue;
}
}else if(cityLevel == 4) {//四线城市
}else if(cityLevel == 4) {//四线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 4 || val > cityBalanceValue * 4)) {
continue;
}
if (regionBalanceValue > 0 && (val < regionBalanceValue / 3 || val > regionBalanceValue * 3)) {
continue;
}
}else if(cityLevel == 5) {//五线城市
}else if(cityLevel == 5) {//五线城市
if (cityBalanceValue > 0 && (val < cityBalanceValue / 3.5 || val > cityBalanceValue * 3.5)) {
continue;
}
@@ -1530,13 +1530,13 @@ public class DistrictSellCalculator implements Calculator<DistrictSellResult, Di
dsp.setValue(val);
ret.add(dsp);
// 对于比较新的样本进行复制,以达到越新的样本影响权重越高的目的
// 对于比较新的样本进行复制,以达到越新的样本影响权重越高的目的
int weightValue = districtSellConfigProvider.getTimeWeights(k.getCity(), k.getRegion(), k.getName(), Math.abs(calcDate.getTime() - dsp.getDate().getTime()));
if(weightValue > 0) {
int randCode = AveragerUtil.makeHashCode(k, dsp.getDate(), FangjiaCalcEnum.SELL);
for (int i = 0; i < weightValue; i++) {
dsp.setValue(val + (randCode % (i + 6)));
ret.add(dsp);//随机产生一个和原始值差不多的数字
ret.add(dsp);//随机产生一个和原始值差不多的数字
}
}
}
@@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
/**
* 小区二手房均价结算结果处理实现
* 小区二手房均价结算结果处理实现
*
* @author xiaoyu
*
@@ -34,17 +34,17 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
private CalcDistrictStatDao calcDistrictStatDao = CalcDistrictStatDao.getInstance();
/**
* 同时向两张表中(district_stat,calc_district_stat)保存
* 同时向两张表中(district_stat,calc_district_stat)保存
*
* <pre>
* <b>如果假定最近计算的价格更加准确的话,那么calc_district_stat中的数据应该是相对准确,而district_stat中的数据相对平稳</b>
* <b>建议在做走势图的时候使用district_stat表中的数据,而估价或者数据调查时使用calc_district_stat中的数据 </b>
* <b>如果假定最近计算的价格更加准确的话,那么calc_district_stat中的数据应该是相对准确,而district_stat中的数据相对平稳</b>
* <b>建议在做走势图的时候使用district_stat表中的数据,而估价或者数据调查时使用calc_district_stat中的数据 </b>
*
* 这两张表的主要区别如下:
* 1.district_stat中的estate_type值"小区"等同于"普通住宅"(最新定义为"普通住宅","别墅")
* 2.district_stat有周涨跌幅(weekend_markup),calc_district_stat没有
* 3.calc_district_stat中保存有该小区均价计算时的关键信息。如:guiding_map,around_object_count等
* 4.calc_district_stat保存的是原始的计算数据,可能会有忽高忽低的情况;而district_stat会对每个计算点的值进行涨跌控制,以保证走势的平稳。
* 这两张表的主要区别如下:
* 1.district_stat中的estate_type值"小区"等同于"普通住宅"(最新定义为"普通住宅","别墅")
* 2.district_stat有周涨跌幅(weekend_markup),calc_district_stat没有
* 3.calc_district_stat中保存有该小区均价计算时的关键信息。如:guiding_map,around_object_count等
* 4.calc_district_stat保存的是原始的计算数据,可能会有忽高忽低的情况;而district_stat会对每个计算点的值进行涨跌控制,以保证走势的平稳。
* </pre>
*
*
@@ -60,7 +60,7 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
}
/**
* 保存入district_stat
* 保存入district_stat
*
* @param city
* @param region
@@ -70,10 +70,10 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
* @return
*/
private boolean saveToDistrictStat(String city, String region, String name, String estateType, DistrictSellResult r) {
if (estateType.indexOf("别墅") > -1) {
estateType = "别墅";
if (estateType.indexOf("别墅") > -1) {
estateType = "别墅";
} else {
estateType = "小区";
estateType = "小区";
}
DBObject q = new BasicDBObject();
@@ -105,15 +105,15 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
districtStat.setValueType(r.getValueType().getType());
districtStat.setWeekend(r.getCalcDate());
districtStat.setChangedMarkup(changedMarkup);
// 显示值
// 显示值
if (weekendMarkup == 0) {
double waveMarkup = createValueWave(city, region, name, estateType, r.getCalcDate());
int val = (int) (r.getValue() * (1.0 + waveMarkup));
districtStat.setAvgPrice(val);
districtStat.setCalcValue(val);// 计算值
districtStat.setCalcValue(val);// 计算值
districtStat.setWeekendMarkup((int) (waveMarkup * 10000.0));
} else {
districtStat.setCalcValue(r.getValue());// 计算值
districtStat.setCalcValue(r.getValue());// 计算值
districtStat.setAvgPrice(r.getValue());
districtStat.setWeekendMarkup(weekendMarkup);
}
@@ -125,7 +125,7 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
}
/**
* 保存入calc_district_stat
* 保存入calc_district_stat
*
* @param city
* @param region
@@ -205,7 +205,7 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
}
// /**
// * 控制涨跌幅,保证曲线平稳
// * 控制涨跌幅,保证曲线平稳
// *
// * @param k
// * @param value
@@ -232,12 +232,12 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
// double markup = (double) (value - lastStat.getAvgPrice()) / (double)
// lastStat.getAvgPrice();
//
// // 如果涨跌幅为0,为了保证曲线有起有落,所以为其定制一个很小的涨跌幅
// // 如果涨跌幅为0,为了保证曲线有起有落,所以为其定制一个很小的涨跌幅
// if (Math.abs(markup) == 0) {
// value += value * (double) ((consVal % 60) / 100.0 / 100.0) * ((consVal %
// 2 == 0) ? 1 : -1);
// } else {
// // 最近一个季度的平均涨跌幅
// // 最近一个季度的平均涨跌幅
// double avgMarkup = districtStatDao.findLatestStatAvgMarkup(city, region,
// name, estateType, calcDate, 13);
// if (avgMarkup == 0) {
@@ -246,7 +246,7 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
// value = (int) (lastStat.getAvgPrice() + lastStat.getAvgPrice() *
// rmarkup);
// } else if (!isValidMarkup(markup, avgMarkup)) {
// // 对平均涨跌幅进行涨跌1.2-2.5倍 (这里与isValidMarkup中的判断应该大致一致)
// // 对平均涨跌幅进行涨跌1.2-2.5倍 (这里与isValidMarkup中的判断应该大致一致)
// double smarkup = (double) (120.0 + (consVal % 130)) / 100.0;
// double rmarkup = (avgMarkup + avgMarkup * smarkup) * (markup >= 0 ? 1 :
// -1);
@@ -258,19 +258,19 @@ public class DistrictSellOperator implements Operator<DistrictKey, DistrictSellR
// }
//
// /**
// * 检查涨跌幅是否正常
// * 检查涨跌幅是否正常
// *
// * @param markup
// * @param avgMarkup
// * @return
// */
// private boolean isValidMarkup(double markup, double avgMarkup) {
// // 每周涨跌1.5%以下属于正常
// // 每周涨跌1.5%以下属于正常
// if (Math.abs(markup) < 0.015) {
// return true;
// }
//
// // 大于平均涨跌幅的2倍属于不正常,这样会造成曲线波动很大
// // 大于平均涨跌幅的2倍属于不正常,这样会造成曲线波动很大
// if (Math.abs(markup) > (avgMarkup + avgMarkup * 2)) {
// return false;
// }
@@ -6,7 +6,7 @@ import com.fangjia.analysis.core.Point;
import org.apache.commons.lang.StringUtils;
/**
* 二手房原始数据点
* 二手房原始数据点
*
* @author xiaoyu
*/
@@ -133,18 +133,18 @@ public class DistrictSellPoint implements Point, Cloneable {
this.url = url;
}
public static final String[] TAGS = {"独栋", "联排", "叠加", "双拼", "花园面积", "泳池", "别墅", "带花园"};
public static final String[] TAGS = {"独栋", "联排", "叠加", "双拼", "花园面积", "泳池", "别墅", "带花园"};
/**
* 是否是普通住宅
* 是否是普通住宅
* @return
*/
public boolean isDistrict() {
return !isVilla(); //只要不是别墅,就判定为普通住宅
return !isVilla(); //只要不是别墅,就判定为普通住宅
}
/**
* 是否是别墅
* 是否是别墅
* @return
*/
public boolean isVilla() {
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
/**
* 小区二手房均价数据提供者实现
* 小区二手房均价数据提供者实现
*
* @author xiaoyu
*/
@@ -83,7 +83,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
if(points.size() < fetchCount * 0.3) {
Seaweed masterSeaweed = districtService.findMasterDistrict(k.getCity(), k.getRegion(), k.getName(), CategoryEnum.DISTRICT.getCategory());
if(masterSeaweed != null) {
Seaweed.EstateTypeEnum masterEstate = (masterSeaweed.getEstateType2().indexOf("别墅") > -1 ? Seaweed.EstateTypeEnum.VILLA : Seaweed.EstateTypeEnum.DISTRICT);
Seaweed.EstateTypeEnum masterEstate = (masterSeaweed.getEstateType2().indexOf("别墅") > -1 ? Seaweed.EstateTypeEnum.VILLA : Seaweed.EstateTypeEnum.DISTRICT);
if(!masterEstate.equals(k.getEstateTypeEnum())) {
List<DistrictSellPoint> subpoints = DistrictSellProvider.getInstance().doFetch(
new DistrictKey(masterSeaweed.getCity(), masterSeaweed.getRegion(), masterSeaweed.getName(), k.getEstateTypeEnum()), lineDate, isCaseReigon, true, true);
@@ -103,13 +103,13 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
/**
* 查询有效样本数据
* 查询有效样本数据
*
* @param districtKey
* @param calcDate
* @param isCaseRegion 是否加区域进行查询
* @param isUseRegionAlias 是否使用区域别名
* @param isUseAlias 是否使用小区别名
* @param isCaseRegion 是否加区域进行查询
* @param isUseRegionAlias 是否使用区域别名
* @param isUseAlias 是否使用小区别名
* @return
*/
public List<DistrictSellPoint> doFetch(DistrictKey districtKey, Date calcDate, boolean isCaseRegion, boolean isUseRegionAlias, boolean isUseAlias) {
@@ -125,7 +125,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
ThreadLocalContainer.getInstance().put("q", query.toString());
int fetchCount = DistrictSellConfigProvider.getInstance().getSampleFetchCount(districtKey.getCity(), districtKey.getRegion(), districtKey.getName());
LOGGER.debug("SampleFetchCount: " + fetchCount);
//如果准确匹配的数据足够,则优先使用匹配区域的数据
//如果准确匹配的数据足够,则优先使用匹配区域的数据
List<Seawater> seawaterList = null;
if(!isCaseRegion) {
seawaterList = seawaterDao.findAll(query, new BasicDBObject("p_date", -1), 0, fetchCount, FIELDS);
@@ -165,7 +165,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
/**
* 转换、删除异常的数据
* 转换、删除异常的数据
*
* @param districtKey
* @param calcDate
@@ -175,23 +175,23 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
private List<DistrictSellPoint> convertSeawaterToDistrictSellPoint(DistrictKey districtKey, Date calcDate, List<Seawater> seawaterList) {
AbstractConfigProvider.Range sampleValueRange = DistrictSellConfigProvider.getInstance().getSampleValueRange(districtKey.getCity(), districtKey.getRegion(), districtKey.getName());
int cityLevel = serverAreaDao.getCityLevel(districtKey.getCity());
//最近一个月城市和区域的平均均价
//最近一个月城市和区域的平均均价
int cityBalanceValue = regionStatService.findRegionStatBalanceValue(districtKey.getCity(), null, null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
int regionBalanceValue = regionStatService.findRegionStatBalanceValue(districtKey.getCity(), districtKey.getRegion(), null, calcDate, DateUtil.getBeforeDay(calcDate, 31));
int districtBalanceValue = districtStatService.findAroundDistrictStat(districtKey, 500, calcDate);
Integer thirdSitePrice = averageStatisticsDao.findThirdpartsGuidePrice(districtKey.getCity(), districtKey.getRegion(), districtKey.getName(), "district", DateUtil.getBeforeDay(calcDate, 31));
List<DistrictSellPoint> ret = new ArrayList<DistrictSellPoint>();
/**被第三方均价过滤的点*/
/**被第三方均价过滤的点*/
List<DistrictSellPoint> thirdSiteNameUnapprovedPoints = new ArrayList<DistrictSellPoint>();
/**别墅样本*/
/**别墅样本*/
List<DistrictSellPoint> villaPoints = new ArrayList<DistrictSellPoint>();
/**小区样本*/
/**小区样本*/
List<DistrictSellPoint> districtPoints = new ArrayList<DistrictSellPoint>();
Set<String> keys = new HashSet<String>();
for (Seawater sw : seawaterList) {
//去除明显异常的数据
//去除明显异常的数据
if (!isValidData(sw)) {
continue;
}
@@ -200,14 +200,14 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
}
keys.add(sw.toKey());
double avgPrice = (double) sw.getTotalPrice() / sw.getArea();
//根据设计的最大最小值过滤
//根据设计的最大最小值过滤
if (avgPrice < sampleValueRange.getLeft().intValue() || avgPrice > sampleValueRange.getRight().intValue()) {
LOGGER.debug("miss left:" + sampleValueRange.getLeft().intValue() + "mis:right:" + sampleValueRange.getRight().intValue() + "-->" + avgPrice);
continue;
}
ThreadLocalContainer.getInstance().put("sampleValueRange", sampleValueRange.getLeft() + "-" + sampleValueRange.getRight());
//根据不同的城市级别进行数据过滤
//根据不同的城市级别进行数据过滤
if(cityLevel <= 1) {
if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 10 || avgPrice > cityBalanceValue * 10)) {
LOGGER.debug("miss cityBalanceValue:" + cityBalanceValue );
@@ -217,28 +217,28 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
LOGGER.debug("miss regionBalanceValue:" + regionBalanceValue );
continue;
}
}else if(cityLevel == 2) {//二线城市
}else if(cityLevel == 2) {//二线城市
if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 7.5 || avgPrice > cityBalanceValue * 7.5)) {
continue;
}
if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 5.5 || avgPrice > regionBalanceValue * 5.5)) {
continue;
}
}else if(cityLevel == 3) {//三线城市
}else if(cityLevel == 3) {//三线城市
if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 6 || avgPrice > cityBalanceValue * 6)) {
continue;
}
if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 4 || avgPrice > regionBalanceValue * 4)) {
continue;
}
}else if(cityLevel == 4) {//四线城市
}else if(cityLevel == 4) {//四线城市
if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 4 || avgPrice > cityBalanceValue * 4)) {
continue;
}
if (regionBalanceValue > 0 && (avgPrice < regionBalanceValue / 3 || avgPrice > regionBalanceValue * 3)) {
continue;
}
}else if(cityLevel == 5) {//五线城市
}else if(cityLevel == 5) {//五线城市
if (cityBalanceValue > 0 && (avgPrice < cityBalanceValue / 3.5 || avgPrice > cityBalanceValue * 3.5)) {
continue;
}
@@ -276,7 +276,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
districtPoints.add(dsp);
}
}
/**如果被第三方均价过滤的点超过20%,则认为第三方均价不靠谱,把过滤的点重新添加到结果集中*/
/**如果被第三方均价过滤的点超过20%,则认为第三方均价不靠谱,把过滤的点重新添加到结果集中*/
if(thirdSiteNameUnapprovedPoints.size() > 0 && thirdSiteNameUnapprovedPoints.size()/(double)seawaterList.size() > 0.2){
for(DistrictSellPoint dsp : thirdSiteNameUnapprovedPoints){
if(dsp.isVilla()){
@@ -301,7 +301,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
}
/**
* 创建查询Query
* 创建查询Query
*
* @param inputCity
* @param inputRegion
@@ -317,7 +317,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
Set<String> namesList = new LinkedHashSet<String>();
namesList.add(inputName);
//是否使用别名
//是否使用别名
if (isUseAlias) {
Seaweed district = districtService.findByPrimaryKey(inputCity, inputRegion, inputName);
if (district != null && district.getAlias() != null) {
@@ -329,7 +329,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
Set<String> regionsList = new LinkedHashSet<String>();
regionsList.add(inputRegion);
//只有进行区域区分,才可以使用区域别名
//只有进行区域区分,才可以使用区域别名
if (isCaseRegion && isUseRegionAlias) {
RegionBlock regionBlock = regionBlockDao.findRegion(inputCity, inputRegion);
if (regionBlock != null && regionBlock.getPattern() != null) {
@@ -384,7 +384,7 @@ public class DistrictSellProvider implements Provider<DistrictKey, DistrictSellP
if (sw.getpDate() == null || sw.getArea() == null || sw.getTotalPrice() == null) {
return false;
}
if(StringUtils.isNotBlank(sw.getName()) && sw.getName().contains("车库")){
if(StringUtils.isNotBlank(sw.getName()) && sw.getName().contains("车库")){
return false;
}
if (sw.getArea() < 30) {
@@ -7,30 +7,30 @@ import java.util.Map;
import com.fangjia.analysis.core.Result;
/**
* 小区二手房均价结果定义
* 小区二手房均价结果定义
*
* @author xiaoyu
*
*/
public class DistrictSellResult implements Result {
private int value; // 运算出的值
private Date calcDate; // 计算日期
private double credit; // 可信度
private double amountCredit; // 数量评分
private double qualityCredit; // 质量评分
private ValueTypeEnum valueType; // 均价计算类型
private int value; // 运算出的值
private Date calcDate; // 计算日期
private double credit; // 可信度
private double amountCredit; // 数量评分
private double qualityCredit; // 质量评分
private ValueTypeEnum valueType; // 均价计算类型
private Integer ownSampleCount; // 自身样本数量
private Integer ownSampleCount; // 自身样本数量
private Integer dealPriceCount; // 成交记录数量
private Integer thirdpartPriceCount; // 第三方价格数量
private Integer dealPriceCount; // 成交记录数量
private Integer thirdpartPriceCount; // 第三方价格数量
// [{"date" : '2014-12', name:'soufang_esf', val:'25660'},...]
private List<Map<String, Object>> thirdpartDetails;
private Integer aroundObjectCount; // 周边对象数量
private Integer aroundSampleCount; // 周边样本数量
private Integer aroundMinDistance; // 最近对象距离
private Integer aroundMaxDistance; // 最远对象距离
private Map<String, Integer> guidingMap; // 指导价
private Integer aroundObjectCount; // 周边对象数量
private Integer aroundSampleCount; // 周边样本数量
private Integer aroundMinDistance; // 最近对象距离
private Integer aroundMaxDistance; // 最远对象距离
private Map<String, Integer> guidingMap; // 指导价
private Map<String, Integer> sampleDetailMap;
@@ -38,20 +38,20 @@ public class DistrictSellResult implements Result {
private Map<String, Integer> tmpMap2;
/**
* 均价计算类型
* 均价计算类型
*
* @author dxy
*
*/
public enum ValueTypeEnum {
GUIDING(1, "指导价"), //
OWN(2, "自身样本"), //
THIRD(3, "第三方"), //
DEAL(4, "交易数据"), //
AROUND(5, "周边楼盘"), //
DERI(6, "推导"), //
DEDU(7, "周边推算"), //
NOWAY(10, "无方式"), //
GUIDING(1, "指导价"), //
OWN(2, "自身样本"), //
THIRD(3, "第三方"), //
DEAL(4, "交易数据"), //
AROUND(5, "周边楼盘"), //
DERI(6, "推导"), //
DEDU(7, "周边推算"), //
NOWAY(10, "无方式"), //
;
private final int type;
@@ -36,10 +36,10 @@ public class Test {
private void test() throws CalcException, FetchException {
DBObject q = new BasicDBObject();
q.put("city", "北京");
q.put("city", "北京");
q.put("visible", 0);
q.put("cat", "district");
q.put("name", "公安小区");
q.put("name", "公安小区");
Iterator<Seaweed> iter = seaweedDao.iteratorAll(q, new String[]{"_id", "city", "region", "name", "estate_type2"});
DistrictSellCalculator calculator = new DistrictSellCalculator();
int c = 0;
@@ -63,7 +63,7 @@ public class Test {
// private void test222() throws CalcException, FetchException {
// DBObject q = new BasicDBObject();
// q.put("city", "上海");
// q.put("city", "上海");
// q.put("visible", 0);
// q.put("cat", "district");
// Iterator<Seaweed> iter = seaweedDao.iteratorAll(q, new String[]{"_id", "city", "region", "name", "estate_type2"});
@@ -15,7 +15,7 @@ import java.util.List;
import java.util.Map;
/**
* 均价调整系数提供者
* 均价调整系数提供者
*/
public abstract class AbstractConfigProvider {
private final Map<String, AveragerConfig> CONFIGS_MAP = new HashMap<String, AveragerConfig>();
@@ -71,7 +71,7 @@ public abstract class AbstractConfigProvider {
}
/**
* 范围对象
* 范围对象
*/
public class Range {
private Number left;
@@ -27,12 +27,12 @@ public class CalcCommandService {
}
public void updateToFail(String id) {
//无法计算的指令直接删除
//无法计算的指令直接删除
calcCommandDao.deleteById(id);
}
public void updateToSuc(String id) {
//处理成功的指令直接删除
//处理成功的指令直接删除
calcCommandDao.deleteById(id);
}
@@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
/**
* 二手房均价系数调整
* 二手房均价系数调整
*/
public class DistrictSellConfigProvider extends AbstractConfigProvider {
@@ -36,7 +36,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
/**
* 样本获取数量
* 样本获取数量
*
* @param city
* @param region
@@ -64,7 +64,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
/**
* 样本取值范围
* 样本取值范围
*
* @param city
* @param region
@@ -111,7 +111,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 自身计算的最低样本数量要求
* 自身计算的最低样本数量要求
*
* @param city
* @param region
@@ -137,7 +137,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 样本有序队列的取值区间
* 样本有序队列的取值区间
*
* @param city
* @param region
@@ -184,7 +184,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
/**
* 周边计算的最大半径
* 周边计算的最大半径
*
* @param city
* @param region
@@ -207,7 +207,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 周边计算采用的小区数量
* 周边计算采用的小区数量
*
* @param city
* @param region
@@ -230,11 +230,11 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 获取时间影响的权重值
* 获取时间影响的权重值
*
* @param city
* @param region
* @param diffTime 匹配
* @param diffTime 匹配
* @return
*/
public Integer getTimeWeights(String city, String region, String name, long diffTime) {
@@ -242,7 +242,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 时间权重
* 时间权重
*
* @param city
* @param region
@@ -303,7 +303,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 价格强制调整系数
* 价格强制调整系数
*
* @param city
* @param region
@@ -328,7 +328,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 主小区影响从小区可信度衰减比例
* 主小区影响从小区可信度衰减比例
*
* @param city
* @param region
@@ -353,7 +353,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 是否把区域作为识别小区的必要条件
* 是否把区域作为识别小区的必要条件
*
* @return
*/
@@ -377,7 +377,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 获取网站权重
* 获取网站权重
*
* @param city
* @param region
@@ -403,7 +403,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 获取网站值的涨跌系数
* 获取网站值的涨跌系数
*
* @param city
* @param region
@@ -430,12 +430,12 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 使用类簇的取值类型
* 使用类簇的取值类型
*
* @param city
* @param region
* @param name
* @return 0-默认 1-中位数 2-最大值 3-最小值
* @return 0-默认 1-中位数 2-最大值 3-最小值
*/
public Integer getValueCluType(String city, String region, String name) {
AveragerConfig averagerConfig = getAveragerConfig(city, region, name);
@@ -454,7 +454,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 指导价的过期时间
* 指导价的过期时间
*
* @param city
* @param region
@@ -479,7 +479,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
/**
* 样本换算需要间隔时间
* 样本换算需要间隔时间
*
* @param city
* @param region
@@ -505,7 +505,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
/**
* 样本与周边对比的相差比例区间
* 样本与周边对比的相差比例区间
*
* @param city
* @param region
@@ -553,7 +553,7 @@ public class DistrictSellConfigProvider extends AbstractConfigProvider {
}
public static void main(String[] args) {
DistrictSellConfigProvider.getInstance().getTimeWeights("深圳", "福田", "嘉葆润金座", 89 * 24 * 3600 * 1000L);
DistrictSellConfigProvider.getInstance().getTimeWeights("深圳", "福田", "嘉葆润金座", 89 * 24 * 3600 * 1000L);
}
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
/**
* 小区查询
* 小区查询
*/
public class DistrictService {
public static final String CATEGORY = Seaweed.CategoryEnum.DISTRICT.getCategory();
@@ -75,7 +75,7 @@ public class DistrictService {
List<Seaweed> nearestDistricts = findNearestDistrictWithCalcType(city, region, name, calcType, radiusMeters, limit);
Map<String, Seaweed> districtMap = new LinkedHashMap<String, Seaweed>();
if (year1 == null && year2 == null) {// 如果竣工时间和入住时间都不存在,则直接返回同类型的附近小区
if (year1 == null && year2 == null) {// 如果竣工时间和入住时间都不存在,则直接返回同类型的附近小区
return new ArrayList<Seaweed>(nearestDistricts);
} else if (year1 != null && year2 == null) {
for (Seaweed nd : nearestDistricts) {
@@ -97,7 +97,7 @@ public class DistrictService {
districtMap.put(nd.getId(), nd);
}
}
} else {// 如果竣工时间和入住时间都存在,则优先选择竣工时间
} else {// 如果竣工时间和入住时间都存在,则优先选择竣工时间
for (Seaweed nd : nearestDistricts) {
Integer y = parseStringToYear(nd.getFinishBuildingDate());
if (y == null) {
@@ -130,7 +130,7 @@ public class DistrictService {
}
/**
* 根据建筑年代获取周边相似的小区
* 根据建筑年代获取周边相似的小区
*
* @param centerLng
* @param centerLat
@@ -219,7 +219,7 @@ public class DistrictService {
public Seaweed findMasterDistrict(String city, String region, String name, String category) {
Seaweed object = findByPrimaryKey(city, region, name);
//是一个小区的分期名称
//是一个小区的分期名称
if(object != null && StringUtils.isNotBlank(object.getMasterDistrictName()) && !object.getMasterDistrictName().equals(name)) {
Seaweed masterObject = findByPrimaryKey(city, region, object.getMasterDistrictName());
if(masterObject != null) {
@@ -230,7 +230,7 @@ public class DistrictService {
}
/**
* 根据价格计算类型和指定小区,获取该小区半径之内的数据
* 根据价格计算类型和指定小区,获取该小区半径之内的数据
*
* @param city
* @param region
@@ -267,7 +267,7 @@ public class DistrictService {
}
/**
* 获取指定小区半径之内的小区
* 获取指定小区半径之内的小区
*
* @param city
* @param region
@@ -304,7 +304,7 @@ public class DistrictService {
/**
* 获取指定经纬度半径之内的小区
* 获取指定经纬度半径之内的小区
*
* @param centerLng
* @param centerLat
@@ -317,7 +317,7 @@ public class DistrictService {
}
/**
* 获取给定条件下、给定经纬度半径之内的小区
* 获取给定条件下、给定经纬度半径之内的小区
* @param fieldQuery
* @param centerLng
* @param centerLat
@@ -341,7 +341,7 @@ public class DistrictService {
return seaweedDao.findAll(q, limit);
}
Pattern PATT = Pattern.compile(".*(\\d{4})[年\\-].*");
Pattern PATT = Pattern.compile(".*(\\d{4})[年\\-].*");
private Integer parseStringToYear(String s) {
if (s == null) {
return null;
@@ -166,7 +166,7 @@ public class RegionStatService {
return (int) CITY_STAT_CACHE2.size();
}
/**
* 计算出城市所有价格的一个平均线
* 计算出城市所有价格的一个平均线
*
* @param city
* @param region
@@ -250,7 +250,7 @@ public class RegionStatService {
/**
* 获取一段时间的平均均价
* 获取一段时间的平均均价
*
* @param city
* @param weekend
@@ -305,7 +305,7 @@ public class RegionStatService {
return (int) (tval / t);
}
//查询所有城市均价数据
//查询所有城市均价数据
public List<AvgUpdateBo> findCityAvgPriceData(String city ,Date weekend) {
Map<String, RegionStat> allCityRegionStatMap = new HashMap<String, RegionStat>();
List<AvgUpdateBo> bos = new ArrayList<AvgUpdateBo>();
@@ -14,7 +14,7 @@ public class ServerAreaService {
return instance;
}
//²éѯServerAre
//查询ServerAre
public ServerArea getServerArea(String display) {
ServerArea serverArea = ServerAreaDao.getInstance().findServerArea(display);
return serverArea;
@@ -49,8 +49,8 @@ public class Test {
//
// }
RegionStatService.getInstance().findRegionStatBalanceValue("上海", "长宁", null, calcDate, DateUtil.getBeforeDay(calcDate, 35));
RegionStatService.getInstance().findRegionStatBalanceValue("上海", "长宁", null, calcDate, DateUtil.getBeforeDay(calcDate, 43));
RegionStatService.getInstance().findRegionStatBalanceValue("上海", "长宁", null, calcDate, DateUtil.getBeforeDay(calcDate, 35));
RegionStatService.getInstance().findRegionStatBalanceValue("上海", "长宁", null, calcDate, DateUtil.getBeforeDay(calcDate, 43));
}
@@ -103,7 +103,7 @@ public class Test {
List<Seaweed> nearestDistricts = findNearestDistrict(seaweedList, seaweed, radiusMeters);
Map<String, Seaweed> districtMap = new LinkedHashMap<String, Seaweed>();
if (year1 == null && year2 == null) {// 如果竣工时间和入住时间都不存在,则直接返回同类型的附近小区
if (year1 == null && year2 == null) {// 如果竣工时间和入住时间都不存在,则直接返回同类型的附近小区
return new ArrayList<Seaweed>(nearestDistricts);
} else if (year1 != null && year2 == null) {
for (Seaweed nd : nearestDistricts) {
@@ -125,7 +125,7 @@ public class Test {
districtMap.put(nd.getId(), nd);
}
}
} else {// 如果竣工时间和入住时间都存在,则优先选择竣工时间
} else {// 如果竣工时间和入住时间都存在,则优先选择竣工时间
for (Seaweed nd : nearestDistricts) {
Integer y = parseStringToYear(nd.getFinishBuildingDate());
if (y == null) {
@@ -233,7 +233,7 @@ public class Test {
return ret;
}
static Pattern PATT = Pattern.compile(".*(\\d{4})[年\\-].*");
static Pattern PATT = Pattern.compile(".*(\\d{4})[年\\-].*");
private static Integer parseStringToYear(String s) {
if (s == null) {
@@ -306,9 +306,9 @@ public class Test {
public static void maineer(String[] args) throws Exception {
Test test = new Test();
String city = "上海";
String region = "松江";
String name = "南场一村";
String city = "上海";
String region = "松江";
String name = "南场一村";
DBObject basicQ = new BasicDBObject();
basicQ.put("city", city);
@@ -322,9 +322,9 @@ public class Test {
}
public void process(String city, String region, double targetLng, double targetLat) {
// String city = "上海";
// String region = "松江";
// String name = "南场一村";
// String city = "上海";
// String region = "松江";
// String name = "南场一村";
DBObject basicQ = new BasicDBObject();
basicQ.put("city", city);
@@ -464,14 +464,14 @@ public class Test {
private void process2() throws IOException, FetchException {
String city = "苏州";
String city = "苏州";
Date endDate = DateUtil.truncateDay(new Date());
Date startDate = DateUtil.getBeforeDay(endDate, 45);
Date calcDate = DateUtil.parseDate("2015-09-20", "yyyy-MM-dd");
DBObject q = new BasicDBObject("city", city).append("cat", "district").append("visible", 0);
// q.put("region", "吴中");
// q.put("name", "月浜三村");
// q.put("region", "吴中");
// q.put("name", "月浜三村");
String[] fields = new String[]{"city", "region", "name", "estate_type2"};
Iterator<Seaweed> iter = SeaweedDao.getInstance().iteratorAll(q, fields);
int c = 0;
@@ -60,13 +60,13 @@ public class Test1 {
}
public void task(){
String city = "上海";
List<List<Object>> datas = ExcelUtils.read("e:\\数据\\上海聚类样本.xlsx");
String city = "上海";
List<List<Object>> datas = ExcelUtils.read("e:\\数据\\上海聚类样本.xlsx");
System.out.println(datas.size());
List<DistrictKey> districtKeys = findDistricts(city, datas);
List<Map<String, Object>> rets = findSamples(districtKeys);
writeExcel(rets, "e:\\数据\\上海聚类结果.xls");
writeExcel(rets, "e:\\数据\\上海聚类结果.xls");
}
@@ -110,7 +110,7 @@ public class Test1 {
continue;
}
//判断是否达到最低样本要求
//判断是否达到最低样本要求
if(sellPoints.size() < districtSellConfigProvider.getOwnTypeLimit(k.getCity(), k.getRegion(), k.getName())) {
result.add(map);
continue;
@@ -118,9 +118,9 @@ public class Test1 {
List<DistrictSellPoint> points = calculator.processingPoint2(k, calcDate, sellPoints);
// 使均值往一端偏移
// 使均值往一端偏移
if (points.size() > 10) {
//排序
//排序
Collections.sort(points,new Comparator<DistrictSellPoint>(){
public int compare(DistrictSellPoint a, DistrictSellPoint b) {
int one = a.getValue();
@@ -289,17 +289,17 @@ public class Test1 {
private void writeExcel(List<Map<String, Object>> rets, String path){
// 第一步,创建一个webbook,对应一个Excel文件
// 第一步,创建一个webbook,对应一个Excel文件
HSSFWorkbook wb = new HSSFWorkbook();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet("结果");
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet("结果");
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
HSSFRow row = sheet.createRow((int) 0);
// 第四步,创建单元格,并设置值表头 设置表头居中
// 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
String[] columns ={"区域","名称","面积(最多)","0_60","61_80","81_100","101_120","121_150","151_1000"};
String[] columns ={"区域","名称","面积(最多)","0_60","61_80","81_100","101_120","121_150","151_1000"};
for(int i=0;i<columns.length;i++){
HSSFCell cell = row.createCell((short) i);
@@ -368,7 +368,7 @@ public class Test1 {
}
// 第六步,将文件存到指定位置
// 第六步,将文件存到指定位置
try
{
FileOutputStream fout = new FileOutputStream(path);
@@ -383,7 +383,7 @@ public class Test1 {
public void exportSqResult(){
String city = "上海";
String city = "上海";
List<RegionBlock> regionBlocks = regionBlockDao.findRegions(city);
List<Map<String, Object>> ret = new ArrayList<Map<String, Object>>();
@@ -401,7 +401,7 @@ public class Test1 {
ret.add(map);
}
writeExcel2(ret, "e:\\数据\\上海区域租售比.xls");
writeExcel2(ret, "e:\\数据\\上海区域租售比.xls");
}
@@ -409,12 +409,12 @@ public class Test1 {
private void writeExcel2(List<Map<String, Object>> rets, String path){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("结果");
HSSFSheet sheet = wb.createSheet("结果");
HSSFRow row = sheet.createRow((int) 0);
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
String[] columns ={"城市","区域","均价","平米租金","租售比"};
String[] columns ={"城市","区域","均价","平米租金","租售比"};
for(int i=0;i<columns.length;i++){
HSSFCell cell = row.createCell((short) i);
@@ -1,7 +1,7 @@
package com.fangjia.analysis.util;
/**
* 异步运行线程
* 异步运行线程
*
* @author xiaoyu
*
@@ -11,7 +11,7 @@ import com.fangjia.core.util.DateUtil;
public final class AveragerUtil {
/**
* 根据小区名称和计算日期创建一个定值
* 根据小区名称和计算日期创建一个定值
*
* @param k
* @param calcDate
@@ -27,7 +27,7 @@ public final class AveragerUtil {
/**
* 获取平均值,数据长度超过3,就去除极值
* 获取平均值,数据长度超过3,就去除极值
*
* @param list
* @return
@@ -6,13 +6,13 @@ import java.util.Collections;
import java.util.List;
/**
* 聚类结果定义
* 聚类结果定义
*
* @author dxy
* @value 表示主要的聚类值
* @secondaryValue 如果这个值存在,说明这些样本有两组相对较大的聚类,样本意见分歧较大
* @mean 加权平均值
* @median 中位数
* @value 表示主要的聚类值
* @secondaryValue 如果这个值存在,说明这些样本有两组相对较大的聚类,样本意见分歧较大
* @mean 加权平均值
* @median 中位数
*/
public final class Cluster {
private int value;
@@ -22,7 +22,7 @@ public final class Cluster {
private int maxValue;
private int minValue;
private int sampleSize; // 样本数量
private int sampleSize; // 样本数量
private double[][] cluters;
public Cluster(double[][] cluters) {
@@ -50,7 +50,7 @@ public final class Cluster {
mean = (int) (total / sampleSize);
List<Double> list = new ArrayList<Double>();
// 如果第一个聚类超过一半,就使用这个聚类
// 如果第一个聚类超过一半,就使用这个聚类
if (cluters[0].length >= sampleSize * 0.5) {
for (int i = 0; i < cluters[0].length; i++) {
list.add(cluters[0][i]);
@@ -63,7 +63,7 @@ public final class Cluster {
}
}
// 如果有两个以上的聚簇,并且第二个聚簇的占比超过35%,说明改聚类有较大的分歧,所以需要把第二聚簇作为次要值考虑
// 如果有两个以上的聚簇,并且第二个聚簇的占比超过35%,说明改聚类有较大的分歧,所以需要把第二聚簇作为次要值考虑
if (cluters.length >= 2) {
if (cluters[1].length >= sampleSize * 0.35) {
long stc = 0;
@@ -111,7 +111,7 @@ public final class Cluster {
/**
* 参与聚类的样本量
* 参与聚类的样本量
*
* @return
*/
@@ -120,7 +120,7 @@ public final class Cluster {
}
/**
* 主要类簇的值的加权平均
* 主要类簇的值的加权平均
*
* @return
*/
@@ -129,7 +129,7 @@ public final class Cluster {
}
/**
* 所有点加权平均
* 所有点加权平均
*
* @return
*/
@@ -138,7 +138,7 @@ public final class Cluster {
}
/**
* 聚类详细数据
* 聚类详细数据
*
* @return
*/
@@ -147,7 +147,7 @@ public final class Cluster {
}
/**
* 最大类簇的中位数
* 最大类簇的中位数
*
* @return
*/
@@ -8,20 +8,20 @@ import java.util.List;
public class DataCluster {
// 聚类桶宽百分比
// 聚类桶宽百分比
public static final int CLUSTER_PERCENT = 5;
// 聚类中最小的成员数
// 聚类中最小的成员数
public static final int MIN_SUPPORT_COUNT = 3;
// 聚类中最大值与最小值的比差
// 聚类中最大值与最小值的比差
public static final double HIGH_DIFFERENCE_PERCENT = 1.2;
// 小区聚类的最小聚类簇个数
// 小区聚类的最小聚类簇个数
public static final int MIN_CLUSTER_COUNT = 1;
// 区域聚类的聚类簇个数
// 区域聚类的聚类簇个数
public static final int REGION_CLUSTER_SIZE = 3;
/**
* 聚类算法
* 聚类算法
*
* @param values
* @return List<Cluster>
@@ -48,7 +48,7 @@ public class DataCluster {
/**
* 聚类算法
* 聚类算法
*
* @param values
* @return List<Cluster>
@@ -76,16 +76,16 @@ public class DataCluster {
/**
*
* @param allAvgs
* 数值列表
* 数值列表
* @param minCluster
* 最少聚出的类个数
* 最少聚出的类个数
* @param percent
* 聚类间距
* 聚类间距
* @param minSize
* 聚类中最小的成员数
* 聚类中最小的成员数
* @param heightDifferencePercent
* 如果聚类中最大值与最小值的比差,只在聚出一个类,并且最小聚类大于一的情况下使用
* @return 聚类列表
* 如果聚类中最大值与最小值的比差,只在聚出一个类,并且最小聚类大于一的情况下使用
* @return 聚类列表
*/
private static double[][] cluster(List<Integer> allAvgs, int minCluster, int percent, int minSize,
double heightDifferencePercent) {
@@ -110,10 +110,10 @@ public class DataCluster {
allClusterSep += allAvgs.get(i);
}
int clusterSep = NumberUtils.round(allClusterSep * percent * 1.0d / (100 * (allAvgs.size() - startfrom)));// 平均数量大小,总值
compStep = NumberUtils.round(clusterSep * 0.5);// 增量
compAvg = allAvgs.get(startfrom) + compStep;// 初始均价大小
startfrom_temp = startfrom;// 起始点
int clusterSep = NumberUtils.round(allClusterSep * percent * 1.0d / (100 * (allAvgs.size() - startfrom)));// 平均数量大小,总值
compStep = NumberUtils.round(clusterSep * 0.5);// 增量
compAvg = allAvgs.get(startfrom) + compStep;// 初始均价大小
startfrom_temp = startfrom;// 起始点
ArrayList<int[]> clusters = new ArrayList<int[]>();
ArrayList<int[]> historyClusters = new ArrayList<int[]>();
@@ -138,14 +138,14 @@ public class DataCluster {
}
if (end - start + 1 >= minSize) {
historyClusters.add(new int[] { start, end });
if (clusters.isEmpty()) {// 新加组
if (clusters.isEmpty()) {// 新加组
clusters.add(new int[] { start, end });
} else {
int[] before = clusters.get(clusters.size() - 1);
if (start <= before[1]) {// 合并
if (start <= before[1]) {// 合并
before[1] = end;
} else {// 新加组
} else {// 新加组
clusters.add(new int[] { start, end });
}
}
@@ -210,7 +210,7 @@ public class DataCluster {
}
/**
* 对大簇进行划分
* 对大簇进行划分
*
* @param cluster
* @param minCluster
@@ -230,7 +230,7 @@ public class DataCluster {
int clusterLength = cluster.length;
int compStep = NumberUtils.round(clusterSep * 0.5);// 增量
int compStep = NumberUtils.round(clusterSep * 0.5);// 增量
int compAvg = allAvgs.get(cluster[0]) + compStep;
while (compAvg <= allAvgs.get(cluster[clusterLength - 1])) {
@@ -276,7 +276,7 @@ public class DataCluster {
int bs = b[1] - b[0];
int cs = c[1] - c[0];
if (bs > as && bs > cs) {// 波峰
if (bs > as && bs > cs) {// 波峰
int avg = 0;
for (int k = b[0]; k <= b[1]; k++) {
avg += allAvgs.get(k);
@@ -286,17 +286,17 @@ public class DataCluster {
topWaveMarkCount++;
flag = 0;
} else if (bs < as && bs < cs) {// 波谷
} else if (bs < as && bs < cs) {// 波谷
waveMark.add(new int[] { i * -1, 0 });
bottomWaveMarkCount++;
flag = 0;
} else if (bs > as && bs == cs) {// 波峰开始
} else if (bs > as && bs == cs) {// 波峰开始
flag = 1;
} else if (bs < as && bs == cs) {// 波谷开始
} else if (bs < as && bs == cs) {// 波谷开始
flag = -1;
} else if (flag == 1 && (bs == as && bs > cs)) {// 波峰
// 下降通道
} else if (flag == 1 && (bs == as && bs > cs)) {// 波峰
// 下降通道
int avg = 0;
for (int k = b[0]; k <= b[1]; k++) {
avg += allAvgs.get(k);
@@ -306,13 +306,13 @@ public class DataCluster {
topWaveMarkCount++;
flag = 0;
} else if (flag == -1 && (bs == as && bs < cs)) {// 波谷
// 上升通道
} else if (flag == -1 && (bs == as && bs < cs)) {// 波谷
// 上升通道
waveMark.add(new int[] { i * -1, 0 });
bottomWaveMarkCount++;
flag = 0;
} else if (bs == as && bs == cs) {// 平滑区
} else if (bs == as && bs == cs) {// 平滑区
} else {
flag = 0;
@@ -322,11 +322,11 @@ public class DataCluster {
List<Integer> bottomMark = new ArrayList<Integer>();
// 取出(minCluster-1)个波谷,断裂
// 取出(minCluster-1)个波谷,断裂
if (bottomWaveMarkCount > 0) {
clusters.clear();
if (topWaveMarkCount > minCluster) {// 按波峰之间的距离选取聚类
if (topWaveMarkCount > minCluster) {// 按波峰之间的距离选取聚类
int startIndex = 2;
@@ -338,12 +338,12 @@ public class DataCluster {
int count = 0;
for (int i = startIndex; i < waveMark.size(); i += 2) {
x[count][0] = waveMark.get(i)[1] - waveMark.get(i - 2)[1]; // 均价间距
x[count][1] = i - 1; // 记录波谷位置
x[count][0] = waveMark.get(i)[1] - waveMark.get(i - 2)[1]; // 均价间距
x[count][1] = i - 1; // 记录波谷位置
count++;
}
// 按间距排序
// 按间距排序
Arrays.sort(x, new Comparator<int[]>() {
public int compare(int[] o1, int[] o2) {
@@ -370,14 +370,14 @@ public class DataCluster {
Collections.sort(bottomMark);
// 合并
// 合并
int lastIndex = 0;
for (int i = 0; i <= bottomMark.size(); i++) {
int start = Integer.MAX_VALUE;
int end = 0;
// 求峰值的平均值,往两边扩散
// 求峰值的平均值,往两边扩散
int bottomIndex = 0;
if (i == bottomMark.size())
bottomIndex = waveMark.size();
@@ -16,10 +16,10 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
public class ExcelUtils{
/**
* 读取Excel 数据
* 读取Excel 数据
* @param file
* @param sheetIndex 数据所在Sheet索引下标
* @param skipRow 要跳过的列数,默认跳过第一列
* @param sheetIndex 数据所在Sheet索引下标
* @param skipRow 要跳过的列数,默认跳过第一列
* @return
* @throws InvalidFormatException
*/
@@ -31,7 +31,7 @@ public class ExcelUtils{
Workbook workbook = WorkbookFactory.create(inp);
workbook.setForceFormulaRecalculation(true);
Sheet sheet = workbook.getSheetAt(0);
//行号
//行号
int rowIndex = 0;
for(Row row : sheet){
rowIndex ++;
@@ -12,7 +12,7 @@ public class NumberUtils {
}
/**
* 判断是否是正数
* 判断是否是正数
* @return
*/
public static boolean isPositive(Number num) {
@@ -33,7 +33,7 @@ public class AvgPriceUpdateController {
public Object houseAvgPriceAction(AvgPriceUpdateModel model) {
Date weekend = DateUtil.getFirstDayOfWeek(new Date());
//城市区域都为空
//城市区域都为空
if(StringUtils.isEmpty(model.getCity())&&StringUtils.isEmpty(model.getRegion())){
List<AvgUpdateBo> avgUpdateBoList = regionStatService.findCityAvgPriceData(null, weekend);
for (AvgUpdateBo avgUpdateBo : avgUpdateBoList) {
@@ -61,7 +61,7 @@ public class AvgPriceUpdateController {
model.setAvgUpdateBos(avgUpdateBoList);
}
//城市不为空,区域为空
//城市不为空,区域为空
if(StringUtils.isNotEmpty(model.getCity())&&StringUtils.isEmpty(model.getRegion())){
model.setSta(1);
List<RegionBlock> regions = null;
@@ -80,7 +80,7 @@ public class AvgPriceUpdateController {
}
model.setAvgUpdateBos(avgUpdateBoList);
}
//城市区域都不为空
//城市区域都不为空
if(StringUtils.isNotEmpty(model.getCity())&&StringUtils.isNotEmpty(model.getRegion())){
model.setSta(2);
List<AvgUpdateBo> avgUpdateBoList = regionStatService.findRegionBlockAvgPriceData(model.getCity(), model.getRegion(), weekend);
@@ -21,7 +21,7 @@ public class CommandController {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getRegion()) || StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getEstateType())
|| StringUtils.isBlank(model.getNewCity()) || StringUtils.isBlank(model.getNewRegion()) || StringUtils.isBlank(model.getNewName()) || StringUtils.isBlank(model.getNewEstateType())) {
mav.setModel(BasicModel.badRequest("参数缺失"));
mav.setModel(BasicModel.badRequest("参数缺失"));
return mav;
}
@@ -26,7 +26,7 @@ public class Controller {
Map<String, Boolean> result = new HashMap<String, Boolean>();
result.put("success", true);
jsonModel.setJsonModel(result);
LOGGER.error("刷新缓存");
LOGGER.error("刷新缓存");
return jsonModel;
}
@@ -65,7 +65,7 @@ public class TaskController {
Test test = new Test();
test.process("上海", "青浦", model.getLng(), model.getLat());
test.process("上海", "青浦", model.getLng(), model.getLat());
return ret;
}
@@ -99,7 +99,7 @@ public class TaskController {
JsonModel ret = new JsonModel();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
DBCollection coll = getColl();
DBCursor cur = coll.find(new BasicDBObject("city", "上海").append("keyword", "学校"));
DBCursor cur = coll.find(new BasicDBObject("city", "上海").append("keyword", "学校"));
while(cur.hasNext()) {
DBObject dbo = cur.next();
Map<String, Object> data = new HashMap<String, Object>();
@@ -15,7 +15,7 @@ public class AveragerModel extends BaseModel {
private String name;
private String estateType;
private String block;
private Date weekend; // 计算日期
private Date weekend; // 计算日期
private List<CityBo> cityBoList;
public String getId() {
@@ -106,7 +106,7 @@ public class BaseModel extends ModelAndViewSupport {
ret = new LinkedHashMap<String, List<ServerArea>>();
for (ServerArea sa : serverAreas) {
if (sa.getDisplay().equals("全国")) {
if (sa.getDisplay().equals("全国")) {
continue;
}
String w = String.valueOf(sa.getSpell().charAt(0)).toUpperCase();
@@ -5,9 +5,9 @@ public class BasicModel {
public enum HttpStatusCodeEnum {
OK(200, "ok"),
BAD_REQUEST(400, "请求参数错误"),
UN_AUTHORIZED(401, "请求未被授权"),
SERVER_ERROR(500, "服务器内部错误");
BAD_REQUEST(400, "请求参数错误"),
UN_AUTHORIZED(401, "请求未被授权"),
SERVER_ERROR(500, "服务器内部错误");
private final Integer code;
private final String msg;
@@ -13,7 +13,7 @@ public class CommandModel extends BaseModel {
private String estateType;
private String block;
private Date weekend; // 计算日期
private Date weekend; // 计算日期
private int priority;
private String newCity;
@@ -2,7 +2,7 @@ package com.fangjia.dal.common;
/**
* query 参数, 比如a>b
* query 参数, 比如a>b
*
* @author Administrator
*
@@ -20,7 +20,7 @@ public class ServerAreaData {
public static ServerArea defaultServerArea;
protected static Map<Integer, ServerArea> homeMapCities = Collections.emptyMap();
protected static Map<String, List<ServerArea>> sectionMap = Collections.emptyMap();
protected static Map<String, List<ServerArea>> sortedServerAreaMapGroupByFirstSpell = Collections.emptyMap();// 按首字母分组,排序号排序
protected static Map<String, List<ServerArea>> sortedServerAreaMapGroupByFirstSpell = Collections.emptyMap();// 按首字母分组,排序号排序
protected static Map<String, ServerArea> nameMap = Collections.emptyMap();
protected static Map<String, ServerArea> spellMap = Collections.emptyMap();
protected static Map<String, ServerArea> displayMap = Collections.emptyMap();
@@ -36,10 +36,10 @@ public class ServerAreaData {
/*****************************************************************************************************/
/**
* 根据name或spell获取ServerArea对象
* 根据name或spell获取ServerArea对象
*
* <p>
* 若name匹配到,则返回ServerArea对象,否则返回spell匹配到的ServerArea对象
* 若name匹配到,则返回ServerArea对象,否则返回spell匹配到的ServerArea对象
* </p>
*
* @param str
@@ -59,7 +59,7 @@ public class ServerAreaData {
}
/**
* 找不到 ,返回NULL
* 找不到 ,返回NULL
*
* @param display
* @return
@@ -79,7 +79,7 @@ public class ServerAreaData {
}
/**
* 通过全拼查找城市
* 通过全拼查找城市
*
* @param spell
* @return
@@ -95,10 +95,10 @@ public class ServerAreaData {
}
/**
* 根据name或spell获取ServerArea对象
* 根据name或spell获取ServerArea对象
*
* <p>
* 若name匹配到,则返回ServerArea对象,否则返回spell匹配到的ServerArea对象
* 若name匹配到,则返回ServerArea对象,否则返回spell匹配到的ServerArea对象
* </p>
*
* @param str
@@ -113,10 +113,10 @@ public class ServerAreaData {
}
/**
* 根据name或spell获取ServerArea对象
* 根据name或spell获取ServerArea对象
*
* <p>
* 若name匹配到,则返回ServerArea对象,否则返回spell匹配到的ServerArea对象
* 若name匹配到,则返回ServerArea对象,否则返回spell匹配到的ServerArea对象
* </p>
*
* @param str
@@ -131,7 +131,7 @@ public class ServerAreaData {
}
/**
* 通过name得到ServerArea对象,找不到返回 defaultServerArea
* 通过name得到ServerArea对象,找不到返回 defaultServerArea
*
* @param spell
* @return
@@ -150,7 +150,7 @@ public class ServerAreaData {
}
/**
* 通过spell得到ServerArea对象,找不到返回null
* 通过spell得到ServerArea对象,找不到返回null
*
* @param spell
* @return
@@ -166,7 +166,7 @@ public class ServerAreaData {
}
/**
* 根据输入的字符串中包含某个城市名称就认为就是那个城市的 比如输入的字符串为浙江省杭州市就认为是杭州市的 如果没有找到某个城市则返回null
* 根据输入的字符串中包含某个城市名称就认为就是那个城市的 比如输入的字符串为浙江省杭州市就认为是杭州市的 如果没有找到某个城市则返回null
*
* @param country
* @return
@@ -241,7 +241,7 @@ public class ServerAreaData {
}
/**
* 获取N个城市名
* 获取N个城市名
*
* @param size
* @return
@@ -259,7 +259,7 @@ public class ServerAreaData {
}
/**
* 获取支持短租的城市列表
* 获取支持短租的城市列表
*
* @return
*/
@@ -20,13 +20,13 @@ import java.util.List;
import java.util.Map;
/**
* 模板工具类
* 模板工具类
*
* @author liupei
*/
public final class TemplateUtils {
/**
* 清理指定字符串中的特殊字符
* 清理指定字符串中的特殊字符
*
* @author liupei
*/
@@ -35,7 +35,7 @@ public final class TemplateUtils {
}
/**
* 清理特定的某个字符串
* 清理特定的某个字符串
*
* @author
*/
@@ -49,14 +49,14 @@ public final class TemplateUtils {
}
/**
* 截取字符串
* 截取字符串
*
* 若原始字符串的长度小于最大截取长度,则直接返回原始字符串
* 若原始字符串的长度小于最大截取长度,则直接返回原始字符串
*
* @param str
* 原始字符串
* 原始字符串
* @param targetLength
* 截取长度
* 截取长度
* @return
*/
public static String cutString(String str, int targetLength) {
@@ -64,12 +64,12 @@ public final class TemplateUtils {
}
/**
* 按字节截取字符串
* 按字节截取字符串
*
* @param str
* 原始字符串
* 原始字符串
* @param targetLength
* 截取长度
* 截取长度
* @return
*/
public static String bCutString(String str, int targetLength) {
@@ -81,7 +81,7 @@ public final class TemplateUtils {
}
/**
* 截取字符串
* 截取字符串
*
* @param str
* @param beginIndex
@@ -93,7 +93,7 @@ public final class TemplateUtils {
}
/**
* 截取字符串
* 截取字符串
*
* @param str
* @param targetLength
@@ -105,7 +105,7 @@ public final class TemplateUtils {
}
/**
* 获取字符在字符串中的index
* 获取字符在字符串中的index
*
* @param str
* @param strChar
@@ -116,7 +116,7 @@ public final class TemplateUtils {
}
/**
* 加密图片url
* 加密图片url
*
* @param u
* @param s
@@ -134,9 +134,9 @@ public final class TemplateUtils {
}
/**
* 格式化均价
* 格式化均价
*
* 将个位和十位直接变为0
* 将个位和十位直接变为0
*
* @param avgPirce
* @return
@@ -146,7 +146,7 @@ public final class TemplateUtils {
}
/**
* 去掉str中的html标记
* 去掉str中的html标记
*
* @param str
* @return
@@ -156,7 +156,7 @@ public final class TemplateUtils {
}
/**
* 移除HTML中的<a>标记
* 移除HTML中的<a>标记
*
* @param htmlDes
* @return
@@ -166,7 +166,7 @@ public final class TemplateUtils {
}
/**
* 全角转半角
* 全角转半角
*
* @param input
* @return
@@ -176,7 +176,7 @@ public final class TemplateUtils {
}
/**
* 转换时间
* 转换时间
*
* @param input
* @return
@@ -186,7 +186,7 @@ public final class TemplateUtils {
}
/**
* 转换时间
* 转换时间
*
* @param input
* @return _tyler
@@ -196,7 +196,7 @@ public final class TemplateUtils {
}
/**
* 去除不支持的编码字符
* 去除不支持的编码字符
*
* @param input
* @return
@@ -206,7 +206,7 @@ public final class TemplateUtils {
}
/**
* 格式化板块
* 格式化板块
*
* @param block
* @return
@@ -216,7 +216,7 @@ public final class TemplateUtils {
}
/**
* 编码
* 编码
*
* @param s
* @return
@@ -227,7 +227,7 @@ public final class TemplateUtils {
}
/**
* 格式化日期
* 格式化日期
*
*/
public static String dateFormat(Date date, String pattern) {
@@ -238,7 +238,7 @@ public final class TemplateUtils {
}
/**
* 获取date前days天的日期
* 获取date前days天的日期
*
* @param date
* @param days
@@ -255,16 +255,16 @@ public final class TemplateUtils {
return StringUtils.replace(text, searchString, replacement);
}
private static final String[] STRONG_KEYS = new String[] { "房价" };
private static final String[] STRONG_VALUES = new String[] { "<strong>房价</strong>" };
private static final String[] STRONG_CLASS_VALUES = new String[] { "<strong class='yhua'>房价</strong>" };
private static final String[] STRONG_KEYS = new String[] { "房价" };
private static final String[] STRONG_VALUES = new String[] { "<strong>房价</strong>" };
private static final String[] STRONG_CLASS_VALUES = new String[] { "<strong class='yhua'>房价</strong>" };
/**
* 关键字加strong格式
* 关键字加strong格式
*
* @param text
* @param isNeedClass
* true:带样式yhua;false:不带class
* true:带样式yhua;false:不带class
* @return
*/
public static String strong(String text, boolean isNeedClass) {
@@ -284,7 +284,7 @@ public final class TemplateUtils {
}
/**
* 获取1~size的随机数
* 获取1~size的随机数
*
* @param size
* @return
@@ -303,13 +303,13 @@ public final class TemplateUtils {
if (publishDate.after(range[0]) && publishDate.before(range[1])) {
int diffHour = DateUtil.getHour(new Date()) - DateUtil.getHour(publishDate);
if (diffHour > 0) {
return diffHour + "小时前";
return diffHour + "小时前";
} else {
int diffMinute = DateUtil.getMinute(new Date()) - DateUtil.getMinute(publishDate);
if (diffMinute <= 0) {
diffMinute = 1;
}
return diffMinute + "分钟前";
return diffMinute + "分钟前";
}
} else {
@@ -17,14 +17,14 @@ public class AvgUpdateBo implements Serializable {
private String weekend;
private Integer avgPrice;
private int weekendMarkup;
private double credit; // 可信度
private Integer valueType; // 计算类型
private double coverage; // 小区覆盖率
private double credit; // 可信度
private Integer valueType; // 计算类型
private double coverage; // 小区覆盖率
private int calcValue;
private String estateType;
private String statStartDate; // 理论上开始计算价格日期
private String sampleStartDate;// 可供计算的样本开始时间
private String calcStartDate; // 均价数据中的开始时间
private String statStartDate; // 理论上开始计算价格日期
private String sampleStartDate;// 可供计算的样本开始时间
private String calcStartDate; // 均价数据中的开始时间
private List<String> alias;
private int cityGrade;
@@ -37,7 +37,7 @@ public class CalcCommandConsumerServlet extends HttpServlet {
LOGGER.info("start " + consumer.getName());
}
//曲线检查启动
//曲线检查启动
if("true".equals(System.getProperty("trendMonitor", "true"))) {
TrendMonitorConsumer.getInstance().start();
LOGGER.info("start TrendMonitorConsumer");
@@ -45,7 +45,7 @@ public class CalcCommandConsumerServlet extends HttpServlet {
LOGGER.info("no TrendMonitorConsumer");
}
//数据迁移启动
//数据迁移启动
if("true".equals(System.getProperty("transferData", "true"))) {
TransferDataConsumer.getInstance().start();
LOGGER.info("start TransferDataConsumer");