速度修改
This commit is contained in:
+40
-7
@@ -13,6 +13,7 @@ import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.GeoHelper
|
||||
import com.fangjia.script.util.JacksonUtil
|
||||
import com.mongodb.DBObject
|
||||
import groovy.sql.Sql
|
||||
import net.sf.json.JSONObject
|
||||
import org.apache.commons.httpclient.util.DateUtil
|
||||
import org.apache.commons.lang.StringUtils
|
||||
@@ -46,6 +47,9 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
|
||||
public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30)
|
||||
|
||||
def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl",
|
||||
"GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver")
|
||||
|
||||
static main(args) {
|
||||
runBatch(new DistrictIndexBatch(), args);
|
||||
}
|
||||
@@ -112,10 +116,10 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
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
|
||||
def potentiality = total_price_index + avg_charge_index + rank_index + avg_cost_index + 4099.978248
|
||||
potentiality = DataHandleUtils.getDoubleRound(6, potentiality)
|
||||
def map = [:]
|
||||
map.id = new ObjectId().toString()
|
||||
map.id = d._id.toString()
|
||||
map.city = d.city
|
||||
map.region = d.region
|
||||
map.name = d.name
|
||||
@@ -130,7 +134,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()
|
||||
@@ -154,7 +158,8 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
}
|
||||
|
||||
def getHousePrice(d, dists, priceMap){
|
||||
def areas = findHouse(d, 20200101, 20220101)
|
||||
//def areas = findHouse(d, 20200101, 20220101)
|
||||
def areas = findHouseByOracle(d._id.toString());
|
||||
def avg_area = null
|
||||
if(areas){
|
||||
avg_area = areas.sum()/areas.size();
|
||||
@@ -179,11 +184,18 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
}
|
||||
|
||||
if(selectDists){
|
||||
def allAreas = []
|
||||
println d.region+" "+d.name+" 周边同建筑年代楼盘:"+selectDists.size()
|
||||
// def allAreas = []
|
||||
def ids = []
|
||||
for(def sd : selectDists){
|
||||
def areaDatas = findHouse(sd, 20190101, 20220101)
|
||||
allAreas.addAll(areaDatas)
|
||||
// //def areaDatas = findHouse(sd, 20190101, 20220101
|
||||
// def areaDatas = findHouseByOracle(sd._id.toString());
|
||||
// allAreas.addAll(areaDatas)
|
||||
ids << sd._id.toString()
|
||||
}
|
||||
|
||||
def idstr = ids.join("','")
|
||||
def allAreas = findHouseByOracle2(idstr);
|
||||
if(allAreas){
|
||||
avg_area = allAreas.sum()/allAreas.size();
|
||||
}
|
||||
@@ -311,6 +323,27 @@ class DistrictIndexBatch extends BaseBatch{
|
||||
}
|
||||
|
||||
|
||||
|
||||
def findHouseByOracle(def distId){
|
||||
|
||||
def sql = "select BUILDAREA from bigdata_forsale_gj where CITYID='440100' AND COMMID='${distId}'";
|
||||
def allRows = []
|
||||
sqlInstance.eachRow(sql,{r->
|
||||
allRows << r.BUILDAREA
|
||||
})
|
||||
return allRows
|
||||
}
|
||||
|
||||
def findHouseByOracle2(def idstr){
|
||||
|
||||
def sql = "select BUILDAREA from bigdata_forsale_gj where CITYID='440100' AND COMMID in ('${idstr}')";
|
||||
def allRows = []
|
||||
sqlInstance.eachRow(sql,{r->
|
||||
allRows << r.BUILDAREA
|
||||
})
|
||||
return allRows
|
||||
}
|
||||
|
||||
def findHouse(def dist, def startDate, def endDate){
|
||||
def nameQuery = getAllName(dist);
|
||||
final StringBuffer sqlBuffer = new StringBuffer()
|
||||
|
||||
Reference in New Issue
Block a user