fangjia-job 1.2
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.fangjia.job.youfang.document;
|
||||||
|
|
||||||
|
import com.fangjia.job.common.base.ReponseData;
|
||||||
|
|
||||||
|
public class DistrictSearchSingleDto extends ReponseData {
|
||||||
|
private DistrictDto result;
|
||||||
|
|
||||||
|
public DistrictDto getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(DistrictDto result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+101
-17
@@ -1,16 +1,29 @@
|
|||||||
package com.fangjia.job.youfang.job;
|
package com.fangjia.job.youfang.job;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
|
|
||||||
import com.dangdang.ddframe.job.api.ShardingContext;
|
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||||
import com.fangjia.job.common.util.RestApiCallUtils;
|
import com.fangjia.job.common.util.RestApiCallUtils;
|
||||||
|
import com.fangjia.job.youfang.document.AgencyInfo;
|
||||||
|
import com.fangjia.job.youfang.document.DistrictBaseInfoDto;
|
||||||
import com.fangjia.job.youfang.document.DistrictDetail;
|
import com.fangjia.job.youfang.document.DistrictDetail;
|
||||||
|
import com.fangjia.job.youfang.document.DistrictDto;
|
||||||
|
import com.fangjia.job.youfang.document.DistrictEvaluateDto;
|
||||||
import com.fangjia.job.youfang.document.DistrictEvaluateSingleDto;
|
import com.fangjia.job.youfang.document.DistrictEvaluateSingleDto;
|
||||||
|
import com.fangjia.job.youfang.document.DistrictInfoDto;
|
||||||
|
import com.fangjia.job.youfang.document.DistrictSearchSingleDto;
|
||||||
import com.fangjia.job.youfang.remote.FshApiRemoteService;
|
import com.fangjia.job.youfang.remote.FshApiRemoteService;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
import com.mongodb.Bytes;
|
import com.mongodb.Bytes;
|
||||||
@@ -26,32 +39,103 @@ public class DistrictInfoJob implements SimpleJob{
|
|||||||
|
|
||||||
@Value("${open.url}")
|
@Value("${open.url}")
|
||||||
private String openApiUrl;
|
private String openApiUrl;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MongoTemplate mongoTemplate;
|
private MongoTemplate mongoTemplate;
|
||||||
|
|
||||||
|
private ExecutorService fixPool = Executors.newFixedThreadPool(5);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ShardingContext shardingContext) {
|
public void execute(ShardingContext shardingContext) {
|
||||||
System.out.println("111");
|
System.out.println("start :"+new Date());
|
||||||
FshApiRemoteService fshApiRemoteService = RestApiCallUtils.getRestClient(FshApiRemoteService.class, openApiUrl);
|
final FshApiRemoteService fshApiRemoteService = RestApiCallUtils.getRestClient(FshApiRemoteService.class, openApiUrl);
|
||||||
Map<String, Object> params = new HashMap<String,Object>();
|
//params.put("type", 4);
|
||||||
params.put("city", "ÉϺ£");
|
|
||||||
params.put("district", "³¤Äþ");
|
|
||||||
params.put("name", "°²Î÷·658Ū");
|
|
||||||
params.put("type", 4);
|
|
||||||
params.put("token", token);
|
|
||||||
DistrictDetail districtDetail = new DistrictDetail();
|
|
||||||
districtDetail.setCity("ÉϺ£");
|
|
||||||
Mongo mongo = mongoTemplate.getDb().getMongo();
|
Mongo mongo = mongoTemplate.getDb().getMongo();
|
||||||
DBCollection collection = mongo.getDB("fangjia").getCollection("seaweed");
|
DBCollection collection = mongo.getDB("fangjia").getCollection("seaweed");
|
||||||
DBCursor cursor = collection.find(new BasicDBObject("cat", "district").append("status", 0),
|
DBCursor cursor = collection.find(new BasicDBObject("cat", "district").append("status", 0).append("city", "上海"),
|
||||||
new BasicDBObject("city", 1).append("region", 1).append("name", 1)).addOption(Bytes.QUERYOPTION_NOTIMEOUT);
|
new BasicDBObject("city", 1).append("region", 1).append("name", 1)).addOption(Bytes.QUERYOPTION_NOTIMEOUT);
|
||||||
|
final Semaphore semaphore = new Semaphore(5);
|
||||||
while (cursor.hasNext()) {
|
while (cursor.hasNext()) {
|
||||||
DBObject data = cursor.next();
|
final DBObject data = cursor.next();
|
||||||
System.out.println(data.toString());
|
try {
|
||||||
|
semaphore.acquire();
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
}
|
||||||
|
fixPool.execute(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
System.out.println("counting...");
|
||||||
|
String city = String.valueOf(data.get("city"));
|
||||||
|
String region = String.valueOf(data.get("region"));
|
||||||
|
String name = String.valueOf(data.get("name"));
|
||||||
|
Map<String, Object> params = new HashMap<String,Object>();
|
||||||
|
params.put("city", city);
|
||||||
|
params.put("district", region);
|
||||||
|
params.put("name", name);
|
||||||
|
params.put("token", token);
|
||||||
|
DistrictDetail districtDetail = mongoTemplate.findOne(Query.query(Criteria.where("city").is(city).and("region").is(region).and("name").is(name)), DistrictDetail.class);
|
||||||
|
if(districtDetail == null) {
|
||||||
|
districtDetail = new DistrictDetail();
|
||||||
|
}
|
||||||
|
districtDetail.setCity(city);
|
||||||
|
districtDetail.setRegion(region);
|
||||||
|
districtDetail.setName(name);
|
||||||
|
DistrictEvaluateSingleDto dto = fshApiRemoteService.getDistrictNewPriceInfo(params);
|
||||||
|
DistrictInfoDto districtInfoDto = fshApiRemoteService.detail(params);
|
||||||
|
Map<String,Object> s = fshApiRemoteService.getAgencyInfo(params);
|
||||||
|
params.put("size", 50);
|
||||||
|
params.put("propertyType", 2);
|
||||||
|
DistrictSearchSingleDto dssDto = fshApiRemoteService.evaluate(params);
|
||||||
|
|
||||||
|
AgencyInfo a = new AgencyInfo();
|
||||||
|
if(s!=null&&(s.get("result")!=null)) {
|
||||||
|
Map<String,Object> result = (Map<String, Object>) s.get("result");
|
||||||
|
a.setAgencyMount(result.get("agencyMount")==null?0:(Integer)result.get("agencyMount"));
|
||||||
|
a.setCitySize(result.get("citySize")==null?0:(Integer)result.get("citySize"));
|
||||||
|
a.setFamousAgency(result.get("famousAgency")==null?0:(Integer)result.get("famousAgency"));
|
||||||
|
a.setMaxCityAgency(result.get("maxCityAgency")==null?0:(Integer)result.get("maxCityAgency"));
|
||||||
|
a.setMomCityLevel(result.get("momCityLevel")==null?0:(Integer)result.get("momCityLevel"));
|
||||||
|
a.setOtherAgency(result.get("otherAgency")==null?0:(Integer)result.get("otherAgency"));
|
||||||
|
}
|
||||||
|
DistrictEvaluateDto deDto = dto==null?null:dto.getResult();
|
||||||
|
if(deDto!=null&&null!=dssDto&&dssDto.getResult()!=null) {
|
||||||
|
DistrictDto dDto = dssDto.getResult();
|
||||||
|
deDto.setUpDownRangecityLevel(dDto.getUpDownRangecityLevel());
|
||||||
|
deDto.setAvgPrice(dDto.getAvgPrice());
|
||||||
|
deDto.setCityDistrictMaxSellPrice(dDto.getCityDistrictMaxSellPrice());
|
||||||
|
deDto.setCityDistrictMinSellPrice(dDto.getCityDistrictMinSellPrice());
|
||||||
|
deDto.setPriceRate(dDto.getPriceRate());
|
||||||
|
}
|
||||||
|
DistrictBaseInfoDto dbiDto = districtInfoDto==null?null:districtInfoDto.getResult();
|
||||||
|
if(dbiDto!=null&&null!=dssDto&&dssDto.getResult()!=null) {
|
||||||
|
DistrictDto add = dssDto.getResult();
|
||||||
|
DistrictDto original = dbiDto.getDistrict();
|
||||||
|
original.setUpDownRangecityLevel(add.getUpDownRangecityLevel());
|
||||||
|
original.setAvgPrice(add.getAvgPrice());
|
||||||
|
original.setCityDistrictMaxSellPrice(add.getCityDistrictMaxSellPrice());
|
||||||
|
original.setCityDistrictMinSellPrice(add.getCityDistrictMinSellPrice());
|
||||||
|
original.setPriceRate(add.getPriceRate());
|
||||||
|
}
|
||||||
|
districtDetail.setAgencyInfo(a);
|
||||||
|
districtDetail.setDistrictBaseInfo(null!=districtInfoDto?districtInfoDto.getResult():null);
|
||||||
|
districtDetail.setDistrictNewPriceInfo(deDto);
|
||||||
|
mongoTemplate.save(districtDetail);
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
semaphore.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// if(count>=10) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
System.out.println("end :"+new Date());
|
||||||
DistrictEvaluateSingleDto dto = fshApiRemoteService.getDistrictNewPriceInfo(params);
|
|
||||||
System.out.println(dto);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
@@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
import com.fangjia.job.common.base.Response;
|
import com.fangjia.job.common.base.Response;
|
||||||
import com.fangjia.job.youfang.document.DistrictEvaluateSingleDto;
|
import com.fangjia.job.youfang.document.DistrictEvaluateSingleDto;
|
||||||
import com.fangjia.job.youfang.document.DistrictInfoDto;
|
import com.fangjia.job.youfang.document.DistrictInfoDto;
|
||||||
|
import com.fangjia.job.youfang.document.DistrictSearchSingleDto;
|
||||||
|
|
||||||
import feign.Param;
|
import feign.Param;
|
||||||
import feign.QueryMap;
|
import feign.QueryMap;
|
||||||
@@ -56,4 +57,8 @@ public interface FshApiRemoteService {
|
|||||||
*/
|
*/
|
||||||
@RequestLine("GET /fsh/detail")
|
@RequestLine("GET /fsh/detail")
|
||||||
public DistrictInfoDto detail(@QueryMap Map<String, Object> queryMap);
|
public DistrictInfoDto detail(@QueryMap Map<String, Object> queryMap);
|
||||||
|
|
||||||
|
//小区估价接口
|
||||||
|
@RequestLine("GET /fsh/evaluate")
|
||||||
|
public DistrictSearchSingleDto evaluate(@QueryMap Map<String, Object> queryMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ zk.namespace=fangjia-job-youfang-test
|
|||||||
|
|
||||||
|
|
||||||
open.url=http://192.168.10.47:9180
|
open.url=http://192.168.10.47:9180
|
||||||
FANGJIA_API_TOKEN="F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"
|
FANGJIA_API_TOKEN=F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB
|
||||||
@@ -93,10 +93,10 @@
|
|||||||
|
|
||||||
</job:simple>
|
</job:simple>
|
||||||
|
|
||||||
<!-- 有房 -->
|
<!-- 有房小区详情信息汇总 -->
|
||||||
<job:simple id="districtInfoJob" class="com.fangjia.job.youfang.job.DistrictInfoJob" registry-center-ref="regCenter"
|
<job:simple id="districtInfoJob" class="com.fangjia.job.youfang.job.DistrictInfoJob" registry-center-ref="regCenter"
|
||||||
sharding-total-count="1" cron="0 01 14 * * ?" sharding-item-parameters=""
|
sharding-total-count="1" cron="30 43 16 * * ?" sharding-item-parameters=""
|
||||||
failover="true" description="【有房】 123"
|
failover="true" description="【有房】 有房小区详情信息汇总"
|
||||||
overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.youfang.handler.CustomJobExceptionHandler">
|
overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.youfang.handler.CustomJobExceptionHandler">
|
||||||
|
|
||||||
<job:listener class="com.fangjia.job.youfang.listener.MessageElasticJobListener"></job:listener>
|
<job:listener class="com.fangjia.job.youfang.listener.MessageElasticJobListener"></job:listener>
|
||||||
|
|||||||
Reference in New Issue
Block a user