Merge branch 'script_gj' into 'master'

城市户均价修改

See merge request !257
This commit is contained in:
2022-01-25 16:52:20 +08:00
@@ -63,16 +63,28 @@ class DistrictIndexBatch extends BaseBatch{
def run(){
def cityCodeDatas = CcbCommonUtils.findCityCodeValue()
def citys = CommonDatautils.findAllCity();
// citys = citys[22..(citys.size()-1)]
citys.remove("上海")
for(def city : citys){
def dists = CommonDatautils.findAllDistrictByCity(city, "district", ["city","alias","region","name", "finish_building_date","estate_charge","lat","lng","lng2","lat2"])
// dists = dists[0..20]
def code = cityCodeDatas.get(city)
calcute(city, dists, code)
def city_avg_total_price = null
if(city!="上海"){
city_avg_total_price = getAvgTotalPrice(city, 20200101, DateUtils.formatDateByPattern(new Date(),"yyyyMMdd"))
if(city_avg_total_price){
city_avg_total_price = city_avg_total_price/10000.0
city_avg_total_price = DataHandleUtils.getDoubleRound(6, city_avg_total_price)
}
}else{
city_avg_total_price = 531.2615913
}
if(city_avg_total_price){
calcute(city, dists, code, city_avg_total_price)
}
println city +" "+city_avg_total_price
}
}
def calcute(city, dists, citycode){
def calcute(city, dists, citycode, city_avg_total_price){
def weekend = DateUtils.getFirstDayOfWeek(new Date());
def priceMap = CommonDatautils.queryDistrictPrice(city, weekend)
def costDatas = getCostByCity(city)
@@ -100,7 +112,7 @@ class DistrictIndexBatch extends BaseBatch{
def total_price_index = 0
if (total_price) {
total_price_index = 286.0134196 * (total_price - 531.2615913) / 313.3693508
total_price_index = 286.0134196 * (total_price - city_avg_total_price) / 313.3693508
total_price_index = DataHandleUtils.getDoubleRound(6, total_price_index)
}
def avg_charge_index = 0
@@ -161,6 +173,23 @@ class DistrictIndexBatch extends BaseBatch{
// ExcelUtils.write("D:\\数据\\评级\\上海综合潜力.xlsx", datas, "数据")
}
def getAvgTotalPrice(city, startDate, endDate){
final StringBuffer sqlBuffer = new StringBuffer()
sqlBuffer.append("SELECT avg(total_price) as avg_total_price FROM \"seawater-20*\" WHERE 1=1")
sqlBuffer.append(" and city = '"+city+"'")
sqlBuffer.append(" and cat = 'sell'")
sqlBuffer.append(" and p_date >="+startDate).append(" and p_date <"+endDate);
ResultSet rs = dataSource.connection.createStatement().executeQuery(sqlBuffer.toString())
def avg_total_price = null
while (rs.next()){
avg_total_price = rs.getDouble("avg_total_price")
}
if(avg_total_price){
avg_total_price = avg_total_price.toInteger()
}
return avg_total_price;
}
def getHousePrice(d, dists, priceMap, citycode){
//def areas = findHouse(d, 20200101, 20220101)