Merge branch 'script_gj' into 'master'

自动添加小区

See merge request !1012
This commit is contained in:
2024-11-19 18:50:20 +08:00
2 changed files with 112 additions and 4 deletions
@@ -4147,6 +4147,96 @@ class CommonDatautils {
}
static def findHousePriceByDate(def city, def region, def name, def alias, def cat, def startDate){
QueryBuilder date_range = QueryBuilders.rangeQuery("p_date").from(startDate).includeLower(true)
QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city))
.must(QueryBuilders.termQuery("region", region))
.must(QueryBuilders.termQuery("cat", cat)).must(date_range)
if(name || alias){
if(!alias){
alias = []
}
if(!alias.contains(name)){
alias.add(name)
}
if(name.contains("弄小区")){
def newName = name.replace("弄小区","弄")
if(!alias.contains(newName)){
alias << newName
}
}
if(alias && alias.size()>0){
BoolQueryBuilder inBuilder = QueryBuilders.boolQuery();
for(def s : alias){
inBuilder.should(QueryBuilders.matchQuery("district_name", s));
}
queryBuilder.must(inBuilder)
}
}
def hosts = ["192.168.0.206","192.168.0.211","192.168.0.212","192.168.0.213","192.168.0.214","192.168.0.215"]
def index = new Random().nextInt(5);
def houses = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", queryBuilder);
def prices = []
if(houses){
for (int k=0;k<houses.size();k++) {
def map = houses[k];
if(map.day_rent_price){
prices << map.day_rent_price
}
}
}
return prices
}
static def findNewPoiDatas(city){
String sql = "select cityname,adname,name,address,location from poi_amap_2024 where (cityname='烟台市' or cityname='北京市') and typecode=120201"
def rets = []
def index= 0
ElasticUtils.executeSqlQuery(sql, { map->
index++
println index
rets << [map.cityname, map.adname, map.name, map.address, map.location.x, map.location.y]
})
return rets;
}
static def findOneThirdNetWorkOffice(city, region, name){
String sql = "select location from office where city='${city}' and region='${region}' and name='${name}'"
def map = [:]
ElasticUtils.executeSqlQuery(sql, { m->
if(m.location && !map){
map = ["lng":m.location.x, "lat":m.location.y]
}
})
return map
}
static def findThirdNetWorkOffice(){
String sql = "select city,region,name,address,location from office where city='烟台' or city='北京'"
def rets = []
def index= 0
ElasticUtils.executeSqlQuery(sql, { map->
index++
println index
if(map.location){
rets << [map.city, map.region, map.name, map.address, map.location.lon, map.location.lat]
}else{
rets << [map.city, map.region, map.name, map.address, "", ""]
}
})
return rets;
}
/**
* 是否是别墅
* @return
@@ -5350,4 +5440,22 @@ class CommonDatautils {
return retMap;
}
static getSeaweedArroundByCat(city, lng, lat, cat) {
try {
def query = new BasicDBObject()
query.append("cat", cat)
query.append("city", city)
query.append("visible", 0)
DBObject sdq = new BasicDBObject();
sdq.put("sd.point", lat + "," + lng);
sdq.put("sd.sfield", "lat_lng");
sdq.put("sd.distance", String.valueOf((double) 1000 / 1000.0));
query.append('$sd', sdq)
return DbUtils.seaweed.find(query).toList()
} catch (Exception e) {
e.printStackTrace()
}
return 0
}
}
@@ -73,8 +73,8 @@ class AutoAddDistrictBatch extends BaseBatch{
def totalCount = new AtomicLong()
for(def i=0;i<keysets.size();i++){
final def key = keysets[i]
// fixedThreadPool.execute(new Runnable() {
// void run() {
fixedThreadPool.execute(new Runnable() {
void run() {
try{
totalCount.addAndGet(1)
def arrs = key.split("##")
@@ -105,8 +105,8 @@ class AutoAddDistrictBatch extends BaseBatch{
} finally {
latch.countDown()
}
// }
// });
}
});
}
latch.await()
return rets