修改MongoDB地址
This commit is contained in:
@@ -78,4 +78,7 @@ public class MongoUtils {
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
//package com.fangjia.open.controllers;
|
||||
//
|
||||
//import com.google.gson.Gson;
|
||||
//import com.google.gson.JsonArray;
|
||||
//import com.google.gson.JsonObject;
|
||||
//import org.apache.http.HttpEntity;
|
||||
//import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
//import org.apache.http.client.methods.HttpPost;
|
||||
//import org.apache.http.entity.ContentType;
|
||||
//import org.apache.http.entity.StringEntity;
|
||||
//import org.apache.http.impl.client.CloseableHttpClient;
|
||||
//import org.apache.http.impl.client.HttpClients;
|
||||
//import org.apache.http.util.EntityUtils;
|
||||
//import sun.misc.BASE64Encoder;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.net.Authenticator;
|
||||
//import java.net.InetSocketAddress;
|
||||
//import java.net.PasswordAuthentication;
|
||||
//import java.net.Proxy;
|
||||
//import java.nio.charset.Charset;
|
||||
//import java.nio.charset.StandardCharsets;
|
||||
//import java.util.Base64;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
////public class Test {
|
||||
//// public static void main(String[] args) throws IOException {
|
||||
//// // 目标URL
|
||||
//// String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign";
|
||||
////
|
||||
//// // 设置代理
|
||||
//// String proxyHost = "tunnel2.qg.net";
|
||||
//// int proxyPort = 14186;
|
||||
////
|
||||
//// // 设置代理用户名和密码
|
||||
//// final String proxyUsername = "113BBC06";
|
||||
//// final String proxyPassword = "3B2FBD05B0AF";
|
||||
////
|
||||
//// // 设置请求的JSON数据
|
||||
//// String address = "江苏省扬州市宝应县安宜镇宝应大道88号";
|
||||
//// String type = "1";
|
||||
//// String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}";
|
||||
////
|
||||
//// // 设置HTTP基本认证
|
||||
//// String authKey = proxyUsername;
|
||||
//// String password = proxyPassword;
|
||||
//// String auth = authKey + ":" + password;
|
||||
//// String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8")));
|
||||
////
|
||||
//// // 创建HTTP客户端
|
||||
//// CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
//// HttpPost httpPost = new HttpPost(targetURL);
|
||||
////
|
||||
//// // 设置代理
|
||||
//// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
|
||||
////
|
||||
//// // 设置代理认证
|
||||
//// Authenticator.setDefault(new Authenticator() {
|
||||
//// protected PasswordAuthentication getPasswordAuthentication() {
|
||||
//// return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray());
|
||||
//// }
|
||||
//// });
|
||||
////
|
||||
//// // 设置请求头
|
||||
//// httpPost.setHeader("Content-Type", "application/json");
|
||||
//// httpPost.setHeader("Accept", "*/*");
|
||||
//// httpPost.setHeader("Host", "146.56.217.44:9010");
|
||||
//// httpPost.setHeader("Proxy-Authorization", authHeader);
|
||||
////
|
||||
//// // 设置请求体
|
||||
//// StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON);
|
||||
//// httpPost.setEntity(stringEntity);
|
||||
////
|
||||
//// // 发送POST请求
|
||||
//// CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
|
||||
////
|
||||
//// // 获取响应
|
||||
//// HttpEntity responseEntity = httpResponse.getEntity();
|
||||
//// String responseString = EntityUtils.toString(responseEntity);
|
||||
//// System.out.println(responseString);
|
||||
////
|
||||
//// // 关闭连接
|
||||
//// httpResponse.close();
|
||||
//// httpClient.close();
|
||||
//// }
|
||||
////}
|
||||
//
|
||||
//public class Test {
|
||||
// public static void main(String[] args) throws IOException {
|
||||
// Map<String, String> map = senRequest("江苏省泰州市靖江市通江路37号", "1");
|
||||
// System.out.println(map);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private static Map<String, String> senRequest(String address, String type) throws IOException {
|
||||
// String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign";
|
||||
// String proxyHost = "tunnel2.qg.net";
|
||||
// int proxyPort = 14186;
|
||||
// final String proxyUsername = "113BBC06";
|
||||
// final String proxyPassword = "3B2FBD05B0AF";
|
||||
// String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}";
|
||||
// String authKey = proxyUsername;
|
||||
// String password = proxyPassword;
|
||||
// String auth = authKey + ":" + password;
|
||||
// String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8")));
|
||||
//
|
||||
// CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
// HttpPost httpPost = new HttpPost(targetURL);
|
||||
// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
|
||||
// Authenticator.setDefault(new Authenticator() {
|
||||
// protected PasswordAuthentication getPasswordAuthentication() {
|
||||
// return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray());
|
||||
// }
|
||||
// });
|
||||
// httpPost.setHeader("Content-Type", "application/json");
|
||||
// httpPost.setHeader("Accept", "*/*");
|
||||
// httpPost.setHeader("Host", "146.56.217.44:9010");
|
||||
// httpPost.setHeader("Proxy-Authorization", authHeader);
|
||||
// StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON);
|
||||
// httpPost.setEntity(stringEntity);
|
||||
//
|
||||
// CloseableHttpResponse httpResponse = null;
|
||||
// int retryCount = 2; // 设置重试次数
|
||||
// int retryDelay = 10; // 设置重试延迟时间(毫秒)
|
||||
// boolean success = false;
|
||||
// for (int i = 0; i < retryCount; i++) {
|
||||
// try {
|
||||
// httpResponse = httpClient.execute(httpPost);
|
||||
// success = true;
|
||||
// break;
|
||||
// } catch (IOException e) {
|
||||
// System.err.println("代理请求失败,进行重试...");
|
||||
// try {
|
||||
// Thread.sleep(retryDelay);
|
||||
// } catch (InterruptedException ex) {
|
||||
// Thread.currentThread().interrupt();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (success) {
|
||||
// HttpEntity responseEntity = httpResponse.getEntity();
|
||||
// String responseString = EntityUtils.toString(responseEntity);
|
||||
//
|
||||
// // 使用 Gson 解析 JSON 字符串
|
||||
// Gson gson = new Gson();
|
||||
// JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class);
|
||||
//
|
||||
//
|
||||
// // 创建 Map 存储各个值
|
||||
// Map<String, String> dataMap = new HashMap<String, String>();
|
||||
//
|
||||
// // 获取各个值并放入 Map
|
||||
// dataMap.put("code", jsonObject.get("code").getAsString());
|
||||
// dataMap.put("msg", jsonObject.get("msg").getAsString());
|
||||
// JsonObject data = jsonObject.getAsJsonObject("data");
|
||||
// dataMap.put("version", data.get("version").getAsString());
|
||||
// dataMap.put("province", data.get("province").getAsString());
|
||||
// dataMap.put("city", data.get("city").getAsString());
|
||||
// dataMap.put("district", data.get("district").getAsString());
|
||||
// dataMap.put("town", data.get("town").getAsString());
|
||||
// dataMap.put("village", data.get("village").getAsString());
|
||||
// dataMap.put("provinceCode", data.get("provinceCode").getAsString());
|
||||
// dataMap.put("cityCode", data.get("cityCode").getAsString());
|
||||
// dataMap.put("districtCode", data.get("districtCode").getAsString());
|
||||
// dataMap.put("townCode", data.get("townCode").getAsString());
|
||||
// dataMap.put("villageCode", data.get("villageCode").getAsString());
|
||||
// dataMap.put("areaCode", data.get("areaCode").getAsString());
|
||||
// dataMap.put("farmer", data.get("farmer").getAsString());
|
||||
// dataMap.put("isGovt", data.get("isGovt").getAsString());
|
||||
// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空
|
||||
// JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray();
|
||||
// if (indusParkList != null) {
|
||||
// JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class);
|
||||
// dataMap.put("devName",jsonObject1.get("indusParkName").getAsString());
|
||||
// dataMap.put("devLevel",jsonObject1.get("indusParkLevel").getAsString());
|
||||
// }
|
||||
//
|
||||
// httpResponse.close();
|
||||
// return dataMap;
|
||||
// } else {
|
||||
// System.err.println("重试次数已用完,请求失败。");
|
||||
// }
|
||||
//
|
||||
// httpClient.close();
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
+7
-6
@@ -2,6 +2,7 @@ package com.fangjia.script.averager
|
||||
|
||||
import com.fangjia.core.util.DataUtil
|
||||
import com.fangjia.core.util.DateUtil
|
||||
import com.fangjia.core.util.MongoUtils
|
||||
import com.fangjia.datastore.driver.DSCollection
|
||||
import com.fangjia.datastore.driver.DSCursor
|
||||
import com.fangjia.datastore.driver.DataStore
|
||||
@@ -9,14 +10,11 @@ import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.cover.EmailTemplate
|
||||
import com.fangjia.script.jms.QueueRedirectConsumer
|
||||
import com.fangjia.script.util.Jms
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.fangjia.script.util.ServerAreaMap
|
||||
import com.google.common.collect.MapDifference
|
||||
import com.google.common.collect.Maps
|
||||
import com.mongodb.*
|
||||
import org.bson.Document
|
||||
import org.bson.types.ObjectId
|
||||
|
||||
/**
|
||||
@@ -29,10 +27,13 @@ class InsertMonitorCalcCommandBatch extends BaseBatch {
|
||||
|
||||
|
||||
public static final DSCollection SEAWEED_COLL = new DataStore("seaweed.db.fangjia.com", 27007).getCollection("fangjia.seaweed")
|
||||
public final static DBCollection REGION_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia').getCollection('region_block')
|
||||
public final static DBCollection COMMAND_COLL = new Mongo("log.mongo.db.fangjia.com", 52002).getDB('fangjia_log').getCollection('calc_command')
|
||||
public final static DBCollection REGION_STAT_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia').getCollection('region_stat')
|
||||
public final static DBCollection DISTRICT_STAT_COLL = new Mongo("mongo.db.fangjia.com", 27017).getDB('fangjia_stat').getCollection('district_stat')
|
||||
public final static DBCollection REGION_STAT_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_stat')
|
||||
public final static DBCollection DISTRICT_STAT_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia_stat', 'district_stat')
|
||||
public final static DBCollection REGION_COLL = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, 'fangjia', 'region_block')
|
||||
|
||||
|
||||
|
||||
public final static DBCollection DISTRICT_STAT_206_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.206",27020)
|
||||
|
||||
public final static def WORKER_MACHINE_IPS = ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1","fangjia-priceanalysis-2"]
|
||||
|
||||
-2
@@ -64,8 +64,6 @@ class AutocompleteDataUpdaterBatch extends BaseBatch {
|
||||
DSCursor cur = SEAWEED_COLL.find(q, fields).batchSize(2000)
|
||||
Iterator<DBObject> iter = cur.iterator()
|
||||
int i = 0
|
||||
|
||||
Map<String, String> keywordMap = new HashMap<String, String>()
|
||||
while(iter.hasNext()) {
|
||||
i++
|
||||
if(i % 100 == 0) {
|
||||
|
||||
@@ -245,7 +245,7 @@ public class CommonUtils {
|
||||
data.put("remark", 'week')
|
||||
data.put("c_date", new Date())
|
||||
if(isTest){
|
||||
data.put("ip", "192.168.0.231")
|
||||
data.put("ip", "192.168.10.29")
|
||||
COMMAND_COLL.update(cmd, new BasicDBObject('$set', data), true, false)
|
||||
}else{
|
||||
data.put("ip", ["fangjia-priceanalysis-0", "fangjia-priceanalysis-1"][new Random().nextInt(2)])
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBCursor
|
||||
import com.mongodb.DBObject
|
||||
import com.fangjia.core.util.MongoUtils
|
||||
|
||||
/**
|
||||
* Created by dxy on 2015/9/14.
|
||||
@@ -43,7 +44,7 @@ public class ServerAreaMap {
|
||||
}
|
||||
|
||||
private static def findServerAreas(host, port, q, sq) {
|
||||
DBCollection collection = MongoUtils.getCollectionByName("fangjia", "server_area", host, port);
|
||||
DBCollection collection = MongoUtils.getDbCollection(com.fangjia.core.Constants.FANGJIA_MONGO_URI, "fangjia", "server_area");
|
||||
DBCursor cur = null;
|
||||
if(q != null) {
|
||||
cur = collection.find(q)
|
||||
|
||||
+16
-11
@@ -1,14 +1,19 @@
|
||||
package com.fangjia.script.wenyan
|
||||
|
||||
import com.fangjia.core.RegionData
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
|
||||
def citys = ["北京", "唐山", "天津", "秦皇岛", "石家庄", "包头", "太原", "丹东", "呼和浩特", "锦州", "沈阳", "吉林", "大连", "牡丹江", "长春", "无锡", "哈尔滨", "扬州", "上海", "徐州", "南京", "温州", "杭州", "金华", "宁波", "蚌埠", "合肥", "安庆", "福州", "泉州", "厦门", "九江", "南昌", "赣州", "济南", "烟台", "青岛", "济宁", "郑州", "洛阳", "武汉", "平顶山", "长沙", "宜昌", "广州", "襄阳", "深圳", "岳阳", "南宁", "常德", "海口", "惠州", "重庆", "湛江", "成都", "韶关", "贵阳", "桂林", "昆明", "北海", "西安", "三亚", "兰州", "泸州", "西宁", "南充", "银川", "遵义", "乌鲁木齐", "大理", "北京", "上海", "广州", "深圳", "重庆", "郑州", "长沙", "西安", "成都", "东莞", "佛山", "杭州", "合肥", "南京", "青岛", "沈阳", "苏州", "天津", "武汉", "珠海", "中山", "长春", "扬州", "烟台", "徐州", "无锡", "温州", "太原", "台州", "石家庄", "绍兴", "厦门", "泉州", "宁波", "南通", "南宁", "南昌", "兰州", "常州", "大连", "福州", "贵阳", "哈尔滨", "海口", "惠州", "济南", "嘉兴", "金华", "昆明", "遵义", "淄博", "株洲", "镇江", "肇庆", "漳州", "湛江", "岳阳", "银川", "宜昌", "盐城", "芜湖", "乌鲁木齐", "唐山", "泰州", "汕头", "三亚", "清远", "秦皇岛", "马鞍山", "洛阳", "柳州", "连云港", "廊坊", "九江", "吉林", "淮安", "湖州", "呼和浩特", "沧州", "保定", "安庆", "张家口", "西宁", "日照", "拉萨", "锦州", "大同", "常德", "北海", "文昌", "陵水", "保亭"]
|
||||
citys.unique()
|
||||
citys.each { def city ->
|
||||
if (RegionData.isCity(city)) {
|
||||
ElasticUtils.executeSqlQuery("select count(*) as count from seawater where p_date > 20210407 and city='${city}'", {
|
||||
println("$city\t${it.count}")
|
||||
})
|
||||
}
|
||||
}
|
||||
import org.apache.commons.mail.SimpleEmail
|
||||
|
||||
import javax.mail.internet.MimeUtility
|
||||
|
||||
EMAIL_SERVER = "smtp.exmail.qq.com"
|
||||
SimpleEmail email = new SimpleEmail();
|
||||
email.setSSL(true);
|
||||
email.setHostName(EMAIL_SERVER);
|
||||
email.setSslSmtpPort("465");
|
||||
email.setCharset("GBK")
|
||||
email.setAuthentication("service@fangjia.com", "iXWzdL69CnzxksaE");
|
||||
email.addTo("wangwenyan@fangjia.com");
|
||||
email.setFrom("service@fangjia.com", MimeUtility.encodeText("房价网大数据中心"), "utf-8");//发送方
|
||||
email.setSubject("标题");
|
||||
email.setContent("你好", "text/html");
|
||||
email.send();
|
||||
@@ -1,62 +1,11 @@
|
||||
package com.fangjia.script.wenyan
|
||||
|
||||
import com.fangjia.core.util.DateUtil
|
||||
import com.fangjia.core.util.Mongo3Utils
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.OpenApiClient
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.client.MongoCollection
|
||||
import net.sf.json.JSONObject
|
||||
import org.apache.http.NameValuePair
|
||||
import org.apache.http.client.config.CookieSpecs
|
||||
import org.apache.http.client.config.RequestConfig
|
||||
import org.apache.http.client.methods.CloseableHttpResponse
|
||||
import org.apache.http.client.methods.HttpGet
|
||||
import org.apache.http.client.utils.URLEncodedUtils
|
||||
import org.apache.http.impl.client.CloseableHttpClient
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager
|
||||
import org.apache.http.message.BasicNameValuePair
|
||||
import org.apache.http.util.EntityUtils
|
||||
import org.bson.Document
|
||||
|
||||
//com.mongodb.client.MongoCollection<Document> GUIDING_PRICE = Mongo3Utils.getDbCollection("fangjia", "guiding_price")
|
||||
//
|
||||
//Mongo3Utils.getDbCollection("fangjia", "confirm_price_data").find(new BasicDBObject("isGuidancePrice", 0)).each { Document doc->
|
||||
// Document item = new Document()
|
||||
// item.put("guiding_type", 0)
|
||||
// item.put("city", doc.city)
|
||||
// item.put("region", doc.region)
|
||||
// item.put("name", doc.district_name)
|
||||
// item.put("guiding_person", doc.user_name)
|
||||
// item.put("category", "district")
|
||||
// item.put("guiding_value", doc.price)
|
||||
// item.put("guiding_date", doc.c_date)
|
||||
// item.put("house_type", 0)
|
||||
// item.put("estate_type", DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(doc.city, doc.region, doc.district_name))?.estate_type2)
|
||||
// item.put("c_date", new Date())
|
||||
// GUIDING_PRICE.insertOne(item)
|
||||
// println(item)
|
||||
//}
|
||||
def keys = []
|
||||
ExcelUtils.read("D:\\Users\\wenyan\\Desktop\\ͶƱ½á¹ûÃ÷ϸ(1).xlsx").each {List item->
|
||||
keys << "${item['A']}_${item['B']}_${item["C"]}".toString()
|
||||
println(item)
|
||||
}
|
||||
MongoCollection<Document> FANGJIA_STAT = Mongo3Utils.getDbCollection("fangjia_stat", "district_stat")
|
||||
def creditMap = [:]
|
||||
FANGJIA_STAT.find(new Document("weekend", DateUtil.parseDate("20200322", "yyyyMMdd"))).each {Document d->
|
||||
def key ="${d.city}_${d.region}_${d.district_name}".toString()
|
||||
if(!keys.contains(key)){
|
||||
Double credit = (int)(d.credit * 10)
|
||||
creditMap[credit] = creditMap.get(credit, 0) + 1
|
||||
}
|
||||
}
|
||||
creditMap.each {def key, value->
|
||||
println("${key}\t${value}")
|
||||
ExcelUtils.read("C:\\Users\\goojia\\Downloads\\꼿제팀섬꿎桿친겼.xlsx",1).each {
|
||||
def one = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(it['B'], it['C'], it['D']))
|
||||
println("${one.lng/10000000000},${one.lat/10000000000}")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user