新增前海测试脚本
This commit is contained in:
+89
@@ -0,0 +1,89 @@
|
||||
package com.fangjia.script.temp.shenjian.qianhai
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.OpenApiClient
|
||||
import com.fangjia.script.xingyebank.CityUtil
|
||||
import net.sf.json.JSONObject
|
||||
import org.apache.commons.lang.StringUtils
|
||||
|
||||
ExcelUtils.multiThreadingModify("D:\\数据\\前海\\前海征信测试数据test.xlsx",{List item->
|
||||
|
||||
if(StringUtils.isBlank(item['B'])){
|
||||
return;
|
||||
}
|
||||
HttpRequest request = new HttpRequest()
|
||||
def params = [:]
|
||||
params["address"] = item['B']
|
||||
params["city"] = getCityFormAddress(item['B'])
|
||||
params["token"] = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"
|
||||
JSONObject json = request.getJsonContent("http://open.fangjia.com/qhzx/propertyDetail", params, "UTF-8")
|
||||
|
||||
if(json.code == 200 && json.result){
|
||||
JSONObject result = json.result
|
||||
item['C'] = CityUtil.getProvinceByCity(result.city)
|
||||
item['D'] = result.city
|
||||
item['E'] = result.district
|
||||
item['F'] = result.name
|
||||
if (result.name) {
|
||||
item['O'] = '住宅地址'
|
||||
} else {
|
||||
item['O'] = '非住宅地址'
|
||||
}
|
||||
item['G'] = result.address
|
||||
item['H'] = result.lng
|
||||
item['I'] = result.lat
|
||||
|
||||
// 小区均价查询
|
||||
int avgPrice = OpenApiClient.queryDistrictAvgPrice(result.city,result.district,result.name)
|
||||
if(avgPrice > 0){
|
||||
item['M'] = avgPrice
|
||||
}
|
||||
params.clear()
|
||||
params["city"] = result.city
|
||||
params["district"] = result.district
|
||||
params["name"] = result.name
|
||||
params["token"] = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"
|
||||
// 小区周边一公里均价
|
||||
json = request.getJsonContent("http://open.fangjia.com/property/aroundAverage", params, "UTF-8")
|
||||
if(json.result){
|
||||
item['J'] = json.getJSONObject("result").averagePrice
|
||||
}
|
||||
}
|
||||
params.clear()
|
||||
params["city"] = getCityFormAddress(item['B'])
|
||||
params["address"] = item['B']
|
||||
params["token"] = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"
|
||||
|
||||
// 地址认证接口
|
||||
json = request.getJsonContent("http://open.fangjia.com/address/realAuth", params, "UTF-8")
|
||||
if(json && json.result){
|
||||
JSONObject result = json.result
|
||||
item['K'] = result.formattedAddress
|
||||
item['L'] = result.authLevel
|
||||
}
|
||||
// 小区详情接口
|
||||
params.clear()
|
||||
params["token"] = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"
|
||||
params["city"] = getCityFormAddress(item['B'])
|
||||
params["name"] = item['F']
|
||||
params["region"] = item['E']
|
||||
|
||||
json = request.getJsonContent("http://open.fangjia.com/district/show", params, "UTF-8")
|
||||
if(json){
|
||||
item['N'] = json.buildType
|
||||
}
|
||||
|
||||
println(item)
|
||||
})
|
||||
|
||||
def getCityFormAddress(String addr){
|
||||
List<String> cities = CommonUtils.findAllCity()
|
||||
for(String city : cities){
|
||||
if(addr.contains(city)){
|
||||
return city
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user