修改: PriceSystem/CalcCmdReceiver.py

修改:     PriceSystem/config/__init__.py
	修改:     PriceSystem/fix/__pycache__/price_fix.cpython-36.pyc
	修改:     PriceSystem/fix/price_fix.py
	修改:     PriceSystem/ones_Sender.py
	修改:     PriceSystem/sell_price/zhuge0118A.py
	修改:     PriceSystem/test.py
This commit is contained in:
罗干
2018-04-27 14:18:17 +08:00
parent c3c5d5a752
commit e7abc0a719
7 changed files with 114 additions and 45 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ import pytz
import os import os
QUEUE = "calc_cmd" QUEUE = "calc_cmd"
#redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db()) redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db())
redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=2) #redis_pool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=2)
logger = fangjia.get_logger("CalcCmdReceiver") logger = fangjia.get_logger("CalcCmdReceiver")
+2 -1
View File
@@ -84,7 +84,8 @@ def get_lg_mongo():
def get_rent_redis_db(): def get_rent_redis_db():
return 5 return 5
def get_save_db():
return 'district_stat_all_0427'
Binary file not shown.
+97 -30
View File
@@ -22,6 +22,7 @@ import time
import fangjia import fangjia
import random import random
import datetime import datetime
import config
''' '''
@@ -32,12 +33,12 @@ estype='普通住宅'
#上海闵行上海康城上海青浦南山雨果 #上海闵行上海康城上海青浦南山雨果
''' '''
client = MongoClient('192.168.10.182',27017) #client = MongoClient('192.168.10.182',27017)
#dt=client.fangjia.district_stat_test #dt=client.fangjia.district_stat_test
#dt=client.fangjia.district_stat #dt=client.fangjia.district_stat
dt=client.fangjia.district_stat_all_0416 #dt=client.fangjia.district_stat_all_0426
dt = stat = fangjia.get_collection("fangjia", "district_stat", config.get_district_stat_host(), config.get_district_stat_port())
def price_list(ct,rl,lk): def price_list(ct,rl,lk):
@@ -50,9 +51,9 @@ def price_list(ct,rl,lk):
dl = dt.find(query,fields).sort([("weekend",-1)] ).limit(10) dl = dt.find(query,fields).sort([("weekend",-1)] ).limit(10)
#dl = dt.find(query).sort([("weekend",1)] ).limit(100) #dl = dt.find(query).sort([("weekend",1)] ).limit(100)
dl1=list(dl) dl1=list(dl)
##print(len(dl1)) ###print(len(dl1))
df=pandas.DataFrame(dl1) df=pandas.DataFrame(dl1)
#print('df=',df[['weekend','avg_price','calc_value']]) ##print('df=',df[['weekend','avg_price','calc_value']])
if df.shape[0]>0: if df.shape[0]>0:
def add_block(df): def add_block(df):
@@ -73,7 +74,7 @@ def price_list(ct,rl,lk):
else: else:
return pd.DataFrame() return pd.DataFrame()
'''
def plot1(x,y): def plot1(x,y):
@@ -90,7 +91,7 @@ def plot1(x,y):
# 把拟合的曲线在这里画出来 # 把拟合的曲线在这里画出来
plt.legend(loc='upper left') plt.legend(loc='upper left')
plt.show() plt.show()
'''
def line_regre(x,y,num): def line_regre(x,y,num):
@@ -100,7 +101,7 @@ def line_regre(x,y,num):
oe=p1(len(x)) oe=p1(len(x))
return oe return oe
##print(p1) #在屏幕上打印拟合多项式 ###print(p1) #在屏幕上打印拟合多项式
#上海经济建设小区崇明 #上海经济建设小区崇明
@@ -120,32 +121,74 @@ estype='普通住宅'
''' '''
def compare(dd1,name,credit,calc_value): def compare(dd1,name,credit,calc_value):
#print('dd1=',dd1)
y=list(dd1[name].dropna()) y=list(dd1[name].dropna())
#print('y=',y) #print('y=',y)
kk=len(y) kk=len(y)
if kk>2: if kk>2:
#kk1=kk-1 #kk1=kk-1
kk1=kk kk1=kk-1
y1=y[:kk1] y1=y[:kk1]
x1=list(range(kk1)) x1=list(range(kk1))
#print('y1=',y1) ##print('y1=',y1)
#plot1(list(range(kk)) ,y) #plot1(list(range(kk)) ,y)
fo=line_regre(x1,y1,1) fo=line_regre(x1,y1,1)
ratio=calc_value/fo ratio=(calc_value-fo)/fo
#print('fo=',fo,name) #print('ratio=',ratio)
if credit>=0.75 and(ratio>0.8 and ratio<1.4) :
#print('cccccc') #print('calc_value=',calc_value)
return calc_value,1 #print('fo=',fo)
elif ratio>0.85 and ratio<1.2:
##print('ratio',ratio)
#print('ddddddddddddd')
##print('fo=',fo,name)
#if credit>=0.75 and(ratio>0.95 and ratio<1.05):
if abs(ratio)<=0.05:
##print('cccccc')
return calc_value,1 return calc_value,1
#elif ratio>0.85 and ratio<1.05:
###print('ratio',ratio)
##print('ddddddddddddd')
#return calc_value,1
else: else:
#print('eeeeeeeeeeeeee') ##print('eeeeeeeeeeeeee')
return fo,0 #print('y[-1]=',y[-1])
def ccp(nihe,znew,ratio):
rr0=abs((nihe-znew)/min(nihe,znew))
#print('nihe=',nihe)
#print('znew=',znew)
#print('rr0=',rr0)
if rr0<=0.07:
#print('kkkkkkkkk')
if ratio>0.05:
return int(znew*1.05)
else:
return int(znew*0.95)
else:
#print('pppp')
#print(ratio)
if ratio>0.05:
#print('lgggg')
return int(nihe*1.05)
else:
return int(nihe*0.95)
foe=ccp(fo,y[-1],ratio)
return foe,0
else: else:
return calc_value,0 return calc_value,0
@@ -154,29 +197,29 @@ def avg_calc(dd1,credit,calc_value):
m=compare(dd1,'calc_value',credit,calc_value) m=compare(dd1,'calc_value',credit,calc_value)
n=compare(dd1,'avg_price',credit,calc_value) n=compare(dd1,'avg_price',credit,calc_value)
#print('m=',m) ##print('m=',m)
#print('n=',n) ##print('n=',n)
if m[1]==1 and n[1]==1: if m[1]==1 and n[1]==1:
return m[0] return m[0]
else : else :
return n[0] return n[0]
'''
def out_price(ct,rl,lk,calc): def out_price(ct,rl,lk,calc):
dd=price_list(ct,rl,lk) dd=price_list(ct,rl,lk)
#print('dd',dd) #print('dd=',dd)
if dd.shape[0]>0: if dd.shape[0]>0:
near_id=dd['_id'].iloc[-1] near_id=dd['_id'].iloc[-1]
##print('near_id',near_id) ###print('near_id',near_id)
credit=dd['credit'].iloc[-1] credit=dd['credit'].iloc[-1]
##print('credit',credit) ###print('credit',credit)
#calc_value=dd['calc_value'].iloc[-1] #calc_value=dd['calc_value'].iloc[-1]
calc_value=calc calc_value=calc
##print('calc_value',calc_value) ###print('calc_value',calc_value)
if 'level' in dd.columns: if 'level' in dd.columns:
@@ -185,7 +228,7 @@ def out_price(ct,rl,lk,calc):
if dd1.shape[0]>1: if dd1.shape[0]>1:
##print('####################') ###print('####################')
return compare(dd1,'calc_value',credit,calc_value)[0],near_id return compare(dd1,'calc_value',credit,calc_value)[0],near_id
@@ -195,9 +238,33 @@ def out_price(ct,rl,lk,calc):
return avg_calc(dd,credit,calc_value),near_id return avg_calc(dd,credit,calc_value),near_id
else: else:
return [] return []
'''
def out_price(ct,rl,lk,calc):
dd=price_list(ct,rl,lk)
#print('dd=',dd)
if dd.shape[0]>0:
near_id=dd['_id'].iloc[-1]
###print('near_id',near_id)
credit=dd['credit'].iloc[-1]
###print('credit',credit)
#calc_value=dd['calc_value'].iloc[-1]
calc_value=calc
###print('calc_value',calc_value)
return compare(dd,'avg_price',credit,calc_value)[0],near_id
else:
return []
#pp=out_price(ct,rl,lk) #pp=out_price(ct,rl,lk)
def update(ct,rl,lk,calc): def update(ct,rl,lk,calc):
@@ -211,11 +278,11 @@ def update(ct,rl,lk,calc):
def update(ct,rl,lk,calc): def update(ct,rl,lk,calc):
dd= out_price(ct,rl,lk,calc) dd= out_price(ct,rl,lk,calc)
#return dd[0] #return dd[0]
print(dd) #print(dd)
if len(dd)>0: if len(dd)>0:
data={} data={}
data['avg_price']=int(dd[0]) data['avg_price']=int(dd[0])
##print(data) ###print(data)
if len(dd)>0: if len(dd)>0:
dt.update_one({"_id": dd[1]}, dt.update_one({"_id": dd[1]},
+1 -1
View File
@@ -48,7 +48,7 @@ def get_district():
return seaweeds return seaweeds
weekend = get_weekend('20180422') weekend = get_weekend('20180429')
#send_cmd({"city": "西安", "region": "雁塔", "name": "鸿景花园", "weekend": get_weekend('20180325')}) #send_cmd({"city": "西安", "region": "雁塔", "name": "鸿景花园", "weekend": get_weekend('20180325')})
if __name__ == "__main__": if __name__ == "__main__":
for seaweed in get_district(): for seaweed in get_district():
+8 -7
View File
@@ -549,12 +549,12 @@ def commonprice(ct, rl, p):
#return '纬度数据有误,有多个经纬度', 0 #return '纬度数据有误,有多个经纬度', 0
else: else:
t1=time.time() #t1=time.time()
#####print("location['lng2'][0]",location['lng2'].iloc[0]) #####print("location['lng2'][0]",location['lng2'].iloc[0])
dd = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 5, ct, rl, p) dd = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 5, ct, rl, p)
print(time.time()-t1,'t1'*10) #print(time.time()-t1,'t1'*10)
# print('dd=',dd,'dd'*20) # print('dd=',dd,'dd'*20)
if dd.shape[0] >= factor: if dd.shape[0] >= factor:
# ####print('$'*50) # ####print('$'*50)
@@ -1429,12 +1429,12 @@ def ghhh(kkg):
return a return a
#stat = fangjia.get_collection("fangjia", "district_stat", config.get_district_stat_host(), config.get_district_stat_port()) stat = fangjia.get_collection("fangjia", "district_stat", config.get_district_stat_host(), config.get_district_stat_port())
#pt = fangjia.get_collection("fangjia_log", "problem_command", config.get_log_mongodb_host(), config.get_log_mongodb_port()) pt = fangjia.get_collection("fangjia_log", "problem_command", config.get_log_mongodb_host(), config.get_log_mongodb_port())
#stat = fangjia.get_collection("fangjia", "Copy_of_district_stat_shanghai_april_ten", '192.168.10.182', 27017) #stat = fangjia.get_collection("fangjia", "Copy_of_district_stat_shanghai_april_ten", '192.168.10.182', 27017)
stat = fangjia.get_collection("fangjia_stat", "shanghai0419", '192.168.10.182', 27017) #stat = fangjia.get_collection("fangjia", config.get_save_db(), '192.168.10.182', 27017)
pt = fangjia.get_collection("fangjia_log", "problem_command", '192.168.10.182', 27017) #pt = fangjia.get_collection("fangjia_log", "problem_command", '192.168.10.182', 27017)
################################################################# #################################################################
def region_district_list_lk(ct, rl, lk): def region_district_list_lk(ct, rl, lk):
@@ -1591,8 +1591,9 @@ def out_put_price(ct, rl, lk, weekend):
p = ghhh(lf[['name', 'alias', 'estate_type2']])[0] p = ghhh(lf[['name', 'alias', 'estate_type2']])[0]
#####print('p=', p) #####print('p=', p)
#t1=time.time()
mm = commonprice(ct, rl, p) mm = commonprice(ct, rl, p)
#print('mmjisuantime=',time.time()-t1,'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy')
#####print('mm=',mm) #####print('mm=',mm)
c_date = datetime.datetime.utcnow() c_date = datetime.datetime.utcnow()
m_date = datetime.datetime.utcnow() m_date = datetime.datetime.utcnow()
+2 -2
View File
@@ -14,7 +14,7 @@ def get_weekend(tt):
pacific = pytz.timezone('Asia/Shanghai') pacific = pytz.timezone('Asia/Shanghai')
return pacific.localize(bb) return pacific.localize(bb)
weekend = get_weekend('20180422') weekend = get_weekend('20180429')
s = time.time() s = time.time()
@@ -22,7 +22,7 @@ s = time.time()
ct='上海' ct='上海'
rl='闵行' rl='闵行'
lk='虹凯小区'#杨浦凤城四村闵行上海康城厦门同安大唐世家二期青岛市北东方小区合肥庐阳海亮红玺台青岛市北东方小区 lk='上海康城'#杨浦凤城四村闵行上海康城厦门同安大唐世家二期青岛市北东方小区合肥庐阳海亮红玺台青岛市北东方小区
#深圳龙岗浪背村宝安吉祥公寓门头沟 泷悦长安北京上海闵行金盛小区江苏昆山象屿珑庭### #深圳龙岗浪背村宝安吉祥公寓门头沟 泷悦长安北京上海闵行金盛小区江苏昆山象屿珑庭###