升级Es驱动版本
This commit is contained in:
@@ -5,6 +5,7 @@ import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import org.apache.lucene.queryparser.classic.QueryParser
|
||||
|
||||
class LogStat {
|
||||
|
||||
@@ -14,19 +15,17 @@ class LogStat {
|
||||
}
|
||||
|
||||
def run(){
|
||||
def datas = ExcelUtils.read("D:\\数据\\建行\\建行匹配小区2.xlsx", 0, 1)
|
||||
println datas.size()
|
||||
ExcelUtils.multiThreadingModify("D:\\数据\\建行\\建行匹配小区2.xlsx",{ d ->
|
||||
def calDate = DateUtil.parseDate(d['D'], "yyyy-MM-dd")
|
||||
ExcelUtils.multiThreadingModify("D:\\data\\建行匹配小区2(1).xlsx",{ d ->
|
||||
def calDate = DateUtil.parseDate(d['M'], "yyyy-MM-dd")
|
||||
def weekend = DateUtils.getFirstDayOfWeek(calDate)
|
||||
def dbo = CommonDatautils.queryDistrictPrice(d['A'], d['B'], d['C'], weekend)
|
||||
def dbo = CommonDatautils.queryDistrictPrice(d['N'], d['O'], d['P'], weekend)
|
||||
if(dbo){
|
||||
d['E'] = dbo.avg_price
|
||||
}
|
||||
|
||||
def district = CommonDatautils.findDistrict(d['A'], d['B'], d['C'], "district")
|
||||
def district = CommonDatautils.findDistrict(d['N'], d['O'], d['P'], "district")
|
||||
if(district){
|
||||
def startDate = DateUtil.addMonth(calDate, -6)
|
||||
def startDate = DateUtil.addMonth(new Date(), -6)
|
||||
def start = startDate.replace("-","").toInteger()
|
||||
def end = DateUtil.formatByPattern(calDate,"yyyyMMdd").toInteger()
|
||||
def alias = []
|
||||
@@ -38,8 +37,9 @@ class LogStat {
|
||||
}else{
|
||||
alias << district.name
|
||||
}
|
||||
def count = findHouses(d['A'], d['B'], d['C'], district.alias, start, end)
|
||||
def count = findHouses(d['N'], d['O'], d['P'], alias, start, end)
|
||||
d['G'] = count
|
||||
println(d)
|
||||
}
|
||||
},0)
|
||||
}
|
||||
@@ -47,13 +47,24 @@ class LogStat {
|
||||
|
||||
def findHouses(def city, def region, def name, def alias, def startDate, def endDate){
|
||||
|
||||
String sql = "select * from seawater-20* where cat=sell and city='${city}' and region='${region}' and district_name in (${alias.join(',')})"
|
||||
def rets = []
|
||||
def aliasStr = escapeExprSpecialWord(alias.join("','"))
|
||||
String sql = "select count(*) as c from latest_seawater where cat='sell' and city='${city}' and p_date > ${startDate} and region='${region}' and district_name in ('${aliasStr}')"
|
||||
def count = 0
|
||||
ElasticUtils.executeSqlQuery(sql,{data->
|
||||
rets << data
|
||||
println data
|
||||
count = data.c
|
||||
})
|
||||
return rets.size()
|
||||
return count
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转义字符串中的特殊字符
|
||||
* 仅过滤Lucene regexps, 其他的勿用
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public static String escapeExprSpecialWord(String keyword) {
|
||||
return QueryParser.escape(keyword);
|
||||
}
|
||||
|
||||
// def findTestDatas(def city, def value) {
|
||||
|
||||
@@ -44,7 +44,7 @@ class ElasticUtils {
|
||||
|
||||
static getEsDataSource(String host){
|
||||
EsDataSource dataSource = new EsDataSource ();
|
||||
dataSource.setUrl("jdbc:es://${host}:9200?timezone=UTC&page.size=240&connect.timeout=240&network.timeout=600&page.timeout=240");
|
||||
dataSource.setUrl("jdbc:es://${host}:9200?timezone=UTC&page.size=240&connect.timeout=240000&network.timeout=60000&page.timeout=240000&query.timeout=90000");
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.setProperty("user","developer");
|
||||
connectionProperties.setProperty("password","5e8edd851d2fdfbd7415232c67367cc3");
|
||||
|
||||
Reference in New Issue
Block a user