update
This commit is contained in:
+23
-4
@@ -5,6 +5,7 @@ import com.fangjia.httpclient.UserAgents
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.common.DataHandleUtils
|
||||
import com.fangjia.script.gj.ccb.FileUtils
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
@@ -43,7 +44,7 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
|
||||
static def targetUrl = "http://192.168.0.12:9200/district_comp_potential/_doc"
|
||||
|
||||
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30)
|
||||
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(1)
|
||||
|
||||
static main(args) {
|
||||
runBatch(new DistrictIndexBatch(), args);
|
||||
@@ -58,6 +59,8 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
def citys = ["上海"]//CommonDatautils.findAllCity();
|
||||
for(def city : citys){
|
||||
def dists = CommonDatautils.findAllDistrictByCity(city, "district", ["city","alias","region","name", "finish_building_date","estate_charge","lat","lng","lng2","lat2"])
|
||||
|
||||
dists = dists[0..20]
|
||||
calcute(city, dists)
|
||||
}
|
||||
}
|
||||
@@ -91,23 +94,27 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
def total_price_index = 0
|
||||
if (total_price) {
|
||||
total_price_index = 286.0134196 * (total_price - 531.2615913) / 313.3693508
|
||||
total_price_index = DataHandleUtils.getDoubleRound(6, total_price_index)
|
||||
}
|
||||
def avg_charge_index = 0
|
||||
if (avg_charge) {
|
||||
avg_charge_index = 139.1374524 * (avg_charge - 1.475882691) / 0.772635241
|
||||
avg_charge_index = DataHandleUtils.getDoubleRound(6, avg_charge_index)
|
||||
}
|
||||
|
||||
def rank_index = 0
|
||||
if (rank) {
|
||||
rank_index = 21.8427926 * (rank - 0.591827186) / 0.261907636
|
||||
rank_index = DataHandleUtils.getDoubleRound(6, rank_index)
|
||||
}
|
||||
|
||||
def avg_cost_index = 0
|
||||
if (avg_cost) {
|
||||
avg_cost_index = 67.0195871700 * (avg_cost - 73.04713255) / 31.3526959
|
||||
avg_cost_index = DataHandleUtils.getDoubleRound(6, avg_cost_index)
|
||||
}
|
||||
def potentiality = avg_cost_index + 4099.978248
|
||||
potentiality = DataHandleUtils.getDoubleRound(2, potentiality)
|
||||
potentiality = DataHandleUtils.getDoubleRound(6, potentiality)
|
||||
def map = [:]
|
||||
map.id = new ObjectId().toString()
|
||||
map.city = d.city
|
||||
@@ -124,7 +131,7 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
datas << [d.city, d.region, d.name, total_price_index, avg_charge_index, rank_index, avg_cost_index,potentiality]
|
||||
|
||||
def newUrl = targetUrl +"/"+map.id
|
||||
httpSaveData(newUrl, map)
|
||||
// httpSaveData(newUrl, map)
|
||||
println "[${totalCount.get()}] " + d.name + " avg_cost: " + avg_cost + " avg_charge:" + avg_charge + " rank:" + rank + " total_price:" + total_price
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace()
|
||||
@@ -135,6 +142,15 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
})
|
||||
}
|
||||
latch.await();
|
||||
|
||||
|
||||
def headers = ["城市","区域","名称","户均价格","物业费","小区价格在区域排名","消费","潜力"]
|
||||
def fileName = "/home/gj/potentiality.dat"
|
||||
if(CommonDatautils.isWindow()){
|
||||
fileName = "D:\\数据\\评级\\上海综合潜力.dat"
|
||||
}
|
||||
|
||||
FileUtils.batchCreateFile(datas, fileName, headers, "utf-8", false);
|
||||
// ExcelUtils.write("D:\\数据\\评级\\上海综合潜力.xlsx", datas, "数据")
|
||||
}
|
||||
|
||||
@@ -169,7 +185,10 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
def areaDatas = findHouse(sd, 20190101, 20220101)
|
||||
allAreas.addAll(areaDatas)
|
||||
}
|
||||
avg_area = allAreas.sum()/allAreas.size();
|
||||
if(allAreas){
|
||||
avg_area = allAreas.sum()/allAreas.size();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user