diff --git a/PriceSystem/CalcCmdReceiver.py b/PriceSystem/CalcCmdReceiver.py index 7d1ab58..29d9a2a 100644 --- a/PriceSystem/CalcCmdReceiver.py +++ b/PriceSystem/CalcCmdReceiver.py @@ -28,12 +28,12 @@ def worker(): try: sell_price.calc_sell_price(cmd) end_time = time.clock() - logger.info("Calc :" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time)) + logger.info("Calc SUC:" + str(cmd) + "\t计算成功,耗时:" + str(end_time - start_time)) except Exception as ex: print(ex) logger.exception(ex) end_time = time.clock() - logger.error("Calc :" + str(cmd) + "\t计算失败,耗时:" + (end_time - start_time), ex) + logger.error("Calc ERROR :" + str(cmd) + "\t计算失败,耗时:" + (end_time - start_time), ex) def format_cmd(cmd): diff --git a/PriceSystem/fangjia/__init__.py b/PriceSystem/fangjia/__init__.py index 6f0a154..fa03698 100644 --- a/PriceSystem/fangjia/__init__.py +++ b/PriceSystem/fangjia/__init__.py @@ -49,7 +49,7 @@ def timer(func): arg_list = list() for arg in args: arg_list.append(str(arg)) - performance_logger.info("函数名:(%s) 参数:(%s) 耗时:%f" % (func.__name__, arg_list, end - begin)) + performance_logger.info("函数名:%-20s\t耗时:%7.4f\t\t参数:(%s)" % (func.__name__, end - begin, arg_list)) return rs return _timer diff --git a/PriceSystem/sell_price/zhuge0118A.py b/PriceSystem/sell_price/zhuge0118A.py index 905b02d..e65f2e3 100644 --- a/PriceSystem/sell_price/zhuge0118A.py +++ b/PriceSystem/sell_price/zhuge0118A.py @@ -25,6 +25,7 @@ import time import fangjia import sklearn.svm import datetime +from fangjia import timer # import yesterday @@ -85,7 +86,7 @@ value_type = pandas.Series([1, 2, 3, 4, 5, 6, 7], # 1:指导价 2:自身样本 3:第三方 4:交易数据 5:周边楼盘, 6:推导 - +@timer def commonprice(ct, rl, p): def add_block(ppd): if 'block' not in ppd.columns: @@ -137,7 +138,7 @@ def commonprice(ct, rl, p): return numpy.array([]) else: return numpy.array([]) - + @timer def take_location(ct, rl, p): dirlt = p[0] @@ -306,6 +307,7 @@ def commonprice(ct, rl, p): # print('df[kk]',df[kk]) return ppp + @timer def neighbor(lng, lat, scale, ct, rl, p): ################### @@ -414,7 +416,7 @@ def commonprice(ct, rl, p): else: km = vv['price'].dropna() return int(k_means(km)) - + @timer def no_source_price(ct, rl, location, p): lk = p[0] hg = location.shape[0] @@ -582,7 +584,7 @@ def commonprice(ct, rl, p): return cc1 else: return cc1 - + @timer def consider_villa(ct, rl, p): # print('villa p=',p) @@ -637,6 +639,7 @@ def commonprice(ct, rl, p): return villa + @timer def dsfjujia(ct, rl, lk): query = {"city": ct, "region": rl, @@ -802,6 +805,7 @@ def commonprice(ct, rl, p): return lzf, anst + @timer def dglg_out1(junjia, neighb): """ @@ -851,6 +855,7 @@ def commonprice(ct, rl, p): location = take_location(ct, rl, p) # ttp=time.time() + neighb = no_source_price(ct, rl, location, p) # print(time.time()-ttp,'m'*20) @@ -956,7 +961,7 @@ def commonprice(ct, rl, p): print('诸葛找房算法') from zhuge import zhuge_consist data['avg'] = data['total_price'] / data['area'] - + @timer def guolv_data11(data, neighb): if type(neighb) is not str: @@ -1071,7 +1076,7 @@ dsf = db136.district_stat # client136 = pymongo.MongoClient('192.168.0.136',27017) # db136 = client136.fangjia - +@timer def region_district_list(ct, rl): # import pandas # client1 = pymongo.MongoClient('192.168.0.136',27017) @@ -1117,13 +1122,13 @@ def region_list(city): data = pandas.DataFrame(pos) return data['name'] - +@timer def add_alias(ppd): if 'alias' not in ppd.columns: ppd['alias'] = '无' return ppd - +@timer def ghhh(kkg): kkg = kkg.fillna('无') a = list() @@ -1141,7 +1146,7 @@ pt = client1.fangjia_log.calc_command ################################################################# - +@timer def region_district_list_lk(ct, rl, lk): # import pandas # client1 = pymongo.MongoClient('192.168.0.136',27017) @@ -1327,7 +1332,4 @@ def out_put_price(ct, rl, lk, weekend): 'remark': 'week', 'category': 'sell', 'weekend': weekend, 'priority': int(0), 'problem': mm[0], }, True - ) - - - + ) \ No newline at end of file diff --git a/PriceSystem/test.py b/PriceSystem/test.py index f256869..b7fa8a8 100644 --- a/PriceSystem/test.py +++ b/PriceSystem/test.py @@ -1,6 +1,7 @@ -import zhuge0118A -import time import datetime +import time + +import sell_price.zhuge0118A as sellPrice s = time.time() ct = '上海' @@ -8,6 +9,6 @@ rl = '奉贤' lk = '杨王村公寓' weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d") -zhuge0118A.out_put_price(ct, rl, lk, weekend) +sellPrice.out_put_price(ct, rl, lk, weekend) e = time.time() print(e - s) diff --git a/PriceSystem/zhuge/zhuge_consist.py b/PriceSystem/zhuge/zhuge_consist.py index cc3665b..214ef28 100644 --- a/PriceSystem/zhuge/zhuge_consist.py +++ b/PriceSystem/zhuge/zhuge_consist.py @@ -10,22 +10,39 @@ from collections import Counter import numpy import collections import re +from fangjia import timer +# @timer +# def url_lable(dmi1): +# +# company_list=['lianjia','zhuge','5i5j','iwjw','fangdd','centanet', 'cityhouse','esf','baixing','ganji','anjuke','58'] +# ##有Bug +# for p in company_list: +# for k in dmi1.index: +# ff=dmi1['url'][k] +# if type(ff)==str: +# if p in dmi1['url'][k]: +# dmi1.loc[k,'url']=p +# print(dmi1) +# return dmi1 + +def url_to_root(url): + company_list = ['lianjia', 'zhuge', '5i5j', 'iwjw', 'fangdd', 'centanet', 'cityhouse', 'esf', 'baixing', 'ganji', + 'anjuke', '58'] + for c in company_list: + if c in url: + return c + + return url + + +@timer def url_lable(dmi1): - - company_list=['lianjia','zhuge','5i5j','iwjw','fangdd','centanet', - 'cityhouse','esf','baixing','ganji','anjuke','58'] - - for p in company_list: - #print('p=',p) - for k in dmi1.index: - #print('k=',k) - #print(dmi1['url'][k]) - ff=dmi1['url'][k] - if type(ff)==str: - - if p in dmi1['url'][k]: - dmi1.loc[k,'url']=p + + house_list = dmi1.to_dict('records') + for h in house_list: + h["url"] = url_to_root(h["url"]) + dmi1 = pandas.DataFrame(house_list) return dmi1 @@ -46,7 +63,7 @@ def drop_rubbish(dd1): #dd=drop_rubbish(dd1) - +@timer def zhuge_out(ddd): #print('我在诸葛文件内',ddd) @@ -311,7 +328,7 @@ def zhuge_out(ddd): #ddd=url_lable(company_list,ddd) - + @timer def opfm(ddo,fm): floor_column=ddo[fm].dropna() @@ -330,7 +347,7 @@ def zhuge_out(ddd): - + @timer def export_pp(ddd): ddo=ddd