diff --git a/projects/fangjia-script/pom.xml b/projects/fangjia-script/pom.xml index d02a60460..47c367a58 100644 --- a/projects/fangjia-script/pom.xml +++ b/projects/fangjia-script/pom.xml @@ -161,11 +161,16 @@ amqp-client 4.12.0 + + mysql mysql-connector-java 5.1.31 + + + com.oracle ojdbc14 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index 0fbbde404..384cba709 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -18,9 +18,12 @@ import net.sf.json.JSONArray import net.sf.json.JSONObject import org.apache.commons.lang.StringUtils import org.bson.types.ObjectId +import org.elasticsearch.common.unit.DistanceUnit import org.elasticsearch.index.query.BoolQueryBuilder import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders +import org.elasticsearch.search.sort.SortBuilders +import org.elasticsearch.search.sort.SortOrder import java.util.regex.Matcher import java.util.regex.Pattern @@ -4227,6 +4230,59 @@ class CommonDatautils { return retMap; } + static def findHousesByLocation(city, region, cat, startDate, endDate, startPrice, endPrice, lng, lat, radius){ + // 构建ElasticSearch查询 + QueryBuilder dateRange = QueryBuilders.rangeQuery("p_date") + .from(startDate) + .to(endDate) + .includeLower(false) + .includeUpper(false) + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery() + .must(dateRange) + + // 地理范围查询 + if (lng && radius) { + QueryBuilder geoQuery = QueryBuilders.geoDistanceQuery("location") + .point(lat, lng) + .distance(radius, DistanceUnit.METERS) + boolQuery.must(geoQuery) + } + + // 价格范围 + if (startPrice || endPrice) { + QueryBuilder priceRange = QueryBuilders.rangeQuery("avg_price") + if (startPrice) { + priceRange.from(startPrice) + } + if (endPrice) { + priceRange.to(endPrice) + } + boolQuery.must(priceRange) + } + + // 分类 + if (cat) { + boolQuery.must(QueryBuilders.termQuery("cat", cat)) + } + + boolQuery.must(QueryBuilders.termQuery("city", city)) + boolQuery.must(QueryBuilders.termQuery("region", region)) + // 执行查询 + 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(hosts.size()) + + // 如果需要排序 + def sortBuilder = SortBuilders.fieldSort("p_date").order( SortOrder.DESC) + + // 执行查询(假设ElasticUtils支持排序和分页) +// def result = ElasticUtils.executeQuery(hosts[index],"seawater-20*",boolQuery) + def result = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", boolQuery); + + return result + } + static def findHouseCount(def city, def region, def name){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy index 862fd5f8f..79e26e435 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy @@ -143,18 +143,19 @@ class DistrictPriceExportBatch extends BaseBatch{ def lastMonthPrice = lastPriceMap.get(rMap.get("_id").toString()) if(curPrice && lastMonthPrice){ - if(dbo.value_type != 1){ - def mom = (curPrice - lastMonthPrice)/lastMonthPrice - if(Math.abs(mom)*100>=6){ - def randMarkup = nextDouble(2, 6) - if(mom < 0){ - mom = DataUtil.roundDouble(randMarkup*(-1)/100, 4) - }else{ - mom = DataUtil.roundDouble(randMarkup/100, 4) - } - curPrice = (int)(lastMonthPrice*mom + lastMonthPrice) - } - } + // 20260115修改,价格不进行控制 +// if(dbo.value_type != 1){ +// def mom = (curPrice - lastMonthPrice)/lastMonthPrice +// if(Math.abs(mom)*100>=6){ +// def randMarkup = nextDouble(2, 6) +// if(mom < 0){ +// mom = DataUtil.roundDouble(randMarkup*(-1)/100, 4) +// }else{ +// mom = DataUtil.roundDouble(randMarkup/100, 4) +// } +// curPrice = (int)(lastMonthPrice*mom + lastMonthPrice) +// } +// } } }else{ curPrice = specialDistsPriceMap.get(rMap.name) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/GongShu.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/GongShu.groovy index b2a89c157..3330670be 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/GongShu.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/GongShu.groovy @@ -20,7 +20,7 @@ class GongShu { } def run() { - String path1 = "D:\\数据\\福州\\福州200个小区抽样价格核验202512.xlsx"; + String path1 = "D:\\数据\\福州\\福州200个小区抽样价格核验202601.xlsx"; // String path1 = "D:\\数据\\福州\\价格比对_20240915.xlsx"; String path2 = "E:\\goojia\\file\\excel文件\\福州\\福州202410小区价格.xlsx"; // String path2 = "E:\\goojia\\file\\excel文件\\福州\\福州202410小区价格.xlsx"; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy index 5fe90170f..ac7bbf3fb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy @@ -14,7 +14,7 @@ import com.mongodb.DBCollection //福州第三方均价统计,发送钉钉消息 //def datas = ExcelUtils.read("d:\\数据\\福州\\福州4月2.xlsx",0,1) //def datas = CsvUtils.read("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202105.csv"); -def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202511.csv") +def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202512.csv") def count0 = 0 def count1 = 0 def count2 = 0 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/house/ExportArroundHouse.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/house/ExportArroundHouse.groovy index 9ba0891ab..b26c9400c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/house/ExportArroundHouse.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/house/ExportArroundHouse.groovy @@ -1,8 +1,10 @@ package com.fangjia.script.gj.house +import com.alibaba.excel.util.DateUtils import com.fangjia.core.util.GeoUtils import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.util.CommonUtils +import com.fangjia.script.util.DateUtil import com.fangjia.script.util.ExcelUtils /** @@ -12,7 +14,8 @@ class ExportArroundHouse { static main(args) { def task = new ExportArroundHouse() - task.run() +// task.run() + task.run2() } def run(){ @@ -69,4 +72,91 @@ class ExportArroundHouse { ExcelUtils.write("D:\\数据\\"+name+"附近房源.xlsx", list, "房源") } } + + + + + def run2(){ +// def name = "光华商业楼" +// def lng = 118.155083 +// def lat = 39.823758 + ExcelUtils.modify("D:\\数据\\宏信息\\商铺和写字楼.xlsx",{d-> + def dist = CommonDatautils.findDistrictById(d['G']) + def lng = dist.lng/10000000000.0 + def lat = dist.lat/10000000000.0 + + def startPrice = d['K'].toString().toDouble().toInteger() + def endPrice = (int)(startPrice + startPrice*0.3) + def lastHouses = [] + + + def houses = [] + for(def i=1;i<100;i++){ + def radius = i*1000 + houses = CommonDatautils.findHousesByLocation(dist.city, dist.region, "office_sell", 20250619, 20260119, startPrice, endPrice,lng, lat, radius) + println dist.city +" "+dist.name+" "+radius +" "+houses.size() + if(houses){ + if(radius<=3000 && houses.size()>=10){ + break; + }else{ + if(houses.size()>=20){ + break; + } + } + } + + } +// if(!houses || (houses && houses.size()<20)){ +// endPrice = (int)(startPrice + startPrice*0.1) +// houses = CommonDatautils.findHousesByLocation(dist.city, dist.region, "shop_sell", 20250419, 20260119, startPrice, endPrice,null, null, null) +// println dist.city +" "+dist.name+" 周边 "+houses.size() +// } + println "-----------------------------------------------------------------------------------------------------------------------" + for(def h : houses){ + if(h.avg_price>startPrice && h.avg_price + ExcelUtils.multiThreadingModify("D:\\数据\\南京\\是否农村.xlsx",{d-> - if(!d['F']){ + if(d['A'] && !d['F']){ def dto = OpenApiUtils.addrVerifyNanjing(null, d['A'], 2) if(dto){ // def dto = jsonObj.result diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/ShBankVillage.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/ShBankVillage.groovy index 022aabf6d..87889ca90 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/ShBankVillage.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/ShBankVillage.groovy @@ -10,7 +10,7 @@ class ShBankVillage { } def run(){ - ExcelUtils.multiThreadingModify("D:\\数据\\上海银行\\内部测试数据.xlsx", { d -> + ExcelUtils.multiThreadingModify("D:\\数据\\上海银行\\区域判定-to估家.xlsx", { d -> if (!d['R'] && d['B']) { def dto = OpenApiUtils.addrVerifyShBank(null, d['B']) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy index 3a641d7b5..2a697daf6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy @@ -26,7 +26,7 @@ class XiaMenVillageBatch extends BaseBatch{ println "输入文件:"+inFileName+" 输出文件:"+outFileName def exists = checkFileExists(outFileName) if(!exists){ - def inExists = checkFileExists(inFileName) + def inExists = checkInFileExists(inFileName) if(inExists){ def rows = [] rows << ["序号","地址","判定后涉农组织类型(城市企业[不含县城企业]、农村企业、县城企业)","所属工业园区或经济开发区"] @@ -97,4 +97,18 @@ class XiaMenVillageBatch extends BaseBatch{ } return existsFlag } + + def checkInFileExists(def fileName){ + def files = XmBankVillageFtpUtils.listInFileNames() + def existsFlag = false + if(files){ + for(def file : files){ + if(file.filename == fileName){ + existsFlag = true + break + } + } + } + return existsFlag + } }