厦门银行脚本修改

This commit is contained in:
2026-02-02 10:58:59 +08:00
parent 03ceb6fed4
commit bcaf5caacc
9 changed files with 185 additions and 19 deletions
+5
View File
@@ -161,11 +161,16 @@
<artifactId>amqp-client</artifactId>
<version>4.12.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
@@ -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){
@@ -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)
@@ -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";
@@ -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
@@ -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<endPrice){
def loc = h.location
if(loc){
h.distance = GeoUtils.calculateDistance(loc.lon, loc.lat, lng, lat)
}
lastHouses << h
}
}
def list = []
if(lastHouses){
list << ["编号","城市","区域","板块","名称","地址","装修","朝向","面积","楼层","楼高","单价","总价","距离","位置","发布时间","标题"]
for(def lh : lastHouses){
def ret = []
ret << lh._id.toString()
ret << lh.city
ret << lh.region
ret << lh.block
ret << lh.district_name
ret << lh.address
ret << lh.fitment
ret << lh.direction
ret << lh.area
ret << lh.floor
ret << lh.height
ret << lh.avg_price
ret << lh.total_price
ret << lh.distance
if(lh.location){
ret << lh.location.lon+","+lh.location.lat
}else{
ret << ""
}
ret << DateUtils.format(DateUtils.parseDate(lh.p_date.toString(),"yyyyMMdd"), "yyyy-MM-dd")
ret << lh.title
list << ret
// list << [lh.houseId.toString(),lh.city,lh.district,lh.block,lh.district_name,lh.address,lh.fitment,lh.direction,lh.area,lh.floor,lh.height,lh.avg_price,lh.total_price,lh.distance,lh.location,lh.p_date,lh.title]
}
}
ExcelUtils.write("D:\\数据\\宏信息\\商铺写字楼房源.xlsx", list, dist.name)
})
}
}
@@ -11,9 +11,9 @@ class NanjiangVillage {
}
def run(){
ExcelUtils.multiThreadingModify("D:\\数据\\南京银行\\新地址核实(县城).xlsx",{d->
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
@@ -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'])
@@ -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
}
}