Merge remote-tracking branch 'origin/master'
This commit is contained in:
+54
-2
@@ -249,7 +249,7 @@ public class AddrSvcController {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("城市不能为空"));
|
||||
return mav;
|
||||
}
|
||||
if (StringUtils.isBlank(model.getKeyword())) {
|
||||
if (StringUtils.isBlank(model.getKeywords())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("关键字不能为空"));
|
||||
return mav;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ public class AddrSvcController {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("city", model.getCity());
|
||||
params.put("region", model.getRegion());
|
||||
params.put("keywords", model.getKeyword());
|
||||
params.put("keywords", model.getKeywords());
|
||||
params.put("page", "0");
|
||||
params.put("size", String.valueOf(model.getMax() == 0 ? 20 : (model.getMax() > 100 ? 100 : model.getMax())));
|
||||
try {
|
||||
@@ -671,6 +671,7 @@ public class AddrSvcController {
|
||||
if (indusParkList != null) {
|
||||
JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class);
|
||||
dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString());
|
||||
dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString());
|
||||
dataMap.put("devDistrict", "是");
|
||||
}
|
||||
}
|
||||
@@ -734,6 +735,57 @@ public class AddrSvcController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地址联想-PRO
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object addressAssociationAction(AddressModel model) {
|
||||
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
HttpRequest request = new HttpRequest();
|
||||
JSONObject json = null;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
|
||||
params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null);
|
||||
params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null);
|
||||
if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) {
|
||||
params.put("lat",model.getLat());
|
||||
params.put("lng",model.getLng());
|
||||
}
|
||||
Integer radius = model.getRadius();
|
||||
params.put("radius", (radius != null && radius != 0) ? radius.toString() : null);
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (json != null) {
|
||||
int code = json.getInt("msgCode");
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(code, msg);
|
||||
if (json.containsKey("result")) {
|
||||
basicModel.setResult(json.get("result"));
|
||||
}
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
public void setDistrictStatService(DistrictStatService districtStatService) {
|
||||
this.districtStatService = districtStatService;
|
||||
}
|
||||
|
||||
+101
-46
@@ -1,6 +1,7 @@
|
||||
package com.fangjia.open.controllers;
|
||||
|
||||
import com.fangjia.core.RegionData;
|
||||
import com.fangjia.core.util.HttpRequest;
|
||||
import com.fangjia.dal.mongo.model.AmapPoi;
|
||||
import com.fangjia.dal.mongo.model.CbmRegion;
|
||||
import com.fangjia.dal.mongo.model.elastic.CbmAmapPoi;
|
||||
@@ -8,10 +9,7 @@ import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.open.dto.UniversalDto;
|
||||
import com.fangjia.open.interceptors.Authority;
|
||||
import com.fangjia.open.interceptors.Role;
|
||||
import com.fangjia.open.model.AntiFraudQuestionModel;
|
||||
import com.fangjia.open.model.BasicModel;
|
||||
import com.fangjia.open.model.PoiSuggestModel;
|
||||
import com.fangjia.open.model.RestfulModelAndView;
|
||||
import com.fangjia.open.model.*;
|
||||
import com.fangjia.service.address.AddressParserService;
|
||||
import com.fangjia.service.address.AddressParserUtil;
|
||||
import com.fangjia.service.address.mode.Address;
|
||||
@@ -19,6 +17,7 @@ import com.fangjia.service.api.AmapPoiService;
|
||||
import com.fangjia.service.bo.Point;
|
||||
import com.fangjia.service.datastore.DistrictService;
|
||||
import com.fangjia.service.mongo.fangjia.CbmRegionService;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -33,14 +32,14 @@ public class PoiController {
|
||||
private DistrictService districtService;
|
||||
private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "addrAlias"};
|
||||
|
||||
public Object getAntiFraudQuestionAction(@Valid AntiFraudQuestionModel model){
|
||||
public Object getAntiFraudQuestionAction(@Valid AntiFraudQuestionModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
Point point = amapPoiService.geocode(model.getCity(), model.getAddress());
|
||||
if(point != null){
|
||||
if (point != null) {
|
||||
List<AmapPoi> poiList = amapPoiService.findAntiFraudPoisAction(point, model.getActualPoiSelectRadius(),
|
||||
model.getFraudPoiSelectMinRadius(), model.getActualCount(), model.getFraudCount());
|
||||
List<UniversalDto> pois = new ArrayList<UniversalDto>();
|
||||
for(AmapPoi poi : poiList){
|
||||
for (AmapPoi poi : poiList) {
|
||||
UniversalDto dto = UniversalDto.newDto();
|
||||
dto.append("id", poi.getId());
|
||||
dto.append("city", poi.getCityname());
|
||||
@@ -54,22 +53,22 @@ public class PoiController {
|
||||
pois.add(dto);
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(pois));
|
||||
}else{
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(Collections.emptyList()));
|
||||
}
|
||||
return mav;
|
||||
|
||||
}
|
||||
|
||||
public Object cmbTipsAction(@Valid PoiSuggestModel poiSuggestModel){
|
||||
public Object cmbTipsAction(@Valid PoiSuggestModel poiSuggestModel) {
|
||||
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
String city = RegionData.formatCity(poiSuggestModel.getCity());
|
||||
if(city != null){
|
||||
if (city != null) {
|
||||
String region = RegionData.formatRegion(city, poiSuggestModel.getRegion());
|
||||
if(!RegionData.isRegion(city, region) && RegionData.getRegionByCity(city) != null){
|
||||
for(String r : RegionData.getRegionByCity(city)){
|
||||
if(region.startsWith(r)){
|
||||
if (!RegionData.isRegion(city, region) && RegionData.getRegionByCity(city) != null) {
|
||||
for (String r : RegionData.getRegionByCity(city)) {
|
||||
if (region.startsWith(r)) {
|
||||
region = r;
|
||||
break;
|
||||
}
|
||||
@@ -78,71 +77,71 @@ public class PoiController {
|
||||
poiSuggestModel.setCity(city);
|
||||
poiSuggestModel.setRegion(region);
|
||||
}
|
||||
if(!RegionData.isRegion(poiSuggestModel.getCity(), poiSuggestModel.getRegion()) || !RegionData.isCity(poiSuggestModel.getCity())){
|
||||
if (!RegionData.isRegion(poiSuggestModel.getCity(), poiSuggestModel.getRegion()) || !RegionData.isCity(poiSuggestModel.getCity())) {
|
||||
CbmRegion cbmRegion = cbmRegionService.findCbmRegion(poiSuggestModel.getCity(), poiSuggestModel.getRegion());
|
||||
if(cbmRegion != null){
|
||||
if (cbmRegion != null) {
|
||||
poiSuggestModel.setCity(cbmRegion.getCity());
|
||||
poiSuggestModel.setRegion(cbmRegion.getRegion());
|
||||
}
|
||||
}
|
||||
if(city == null){
|
||||
if (city == null) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("city非法"));
|
||||
return mav;
|
||||
}
|
||||
Address address = addressParserService.standardizeForSearch(poiSuggestModel.getCity(), poiSuggestModel.getKeywords());
|
||||
String keywords = poiSuggestModel.getKeywords();
|
||||
if(StringUtils.isNotBlank(address.getEffectiveAddress())){
|
||||
if (StringUtils.isNotBlank(address.getEffectiveAddress())) {
|
||||
poiSuggestModel.setKeywords(address.getEffectiveAddress());
|
||||
poiSuggestModel.setCity(address.getCity());
|
||||
if(StringUtils.isNotBlank(address.getDistrict())){
|
||||
if (StringUtils.isNotBlank(address.getDistrict())) {
|
||||
poiSuggestModel.setRegion(address.getDistrict());
|
||||
}
|
||||
}
|
||||
List<District> districts = districtService.cmbSearch(poiSuggestModel.getCity(), poiSuggestModel.getRegion(), poiSuggestModel.getKeywords(), PROPERTY_SEARCH_API_FIELDS, poiSuggestModel.getLimit());
|
||||
List<UniversalDto> dtos = new ArrayList<UniversalDto>();
|
||||
Set<String> keys = new HashSet<String>();
|
||||
for(District district : districts){
|
||||
for (District district : districts) {
|
||||
UniversalDto dto = new UniversalDto();
|
||||
dto.append("city", district.getCity());
|
||||
dto.append("region", district.getRegion());
|
||||
if(district.getName().contains(poiSuggestModel.getKeywords()) || district.getAlias() == null){
|
||||
if (district.getName().contains(poiSuggestModel.getKeywords()) || district.getAlias() == null) {
|
||||
dto.append("name", district.getName());
|
||||
keys.add(district.getName());
|
||||
dto.append("address", district.getAddress());
|
||||
}else{
|
||||
} else {
|
||||
dto.append("name", getLookLikeString(poiSuggestModel.getKeywords(), district.getAlias(), district.getName()));
|
||||
keys.add((String)dto.get("name"));
|
||||
if(district.getAddress() == null || district.getAddress().contains(poiSuggestModel.getKeywords()) || district.getAddrAlias() == null){
|
||||
keys.add((String) dto.get("name"));
|
||||
if (district.getAddress() == null || district.getAddress().contains(poiSuggestModel.getKeywords()) || district.getAddrAlias() == null) {
|
||||
dto.append("address", district.getAddress());
|
||||
}else{
|
||||
} else {
|
||||
dto.append("address", getLookLikeString(poiSuggestModel.getKeywords(), district.getAddrAlias(), district.getAddress()));
|
||||
}
|
||||
}
|
||||
dtos.add(dto);
|
||||
}
|
||||
if(dtos.size() == poiSuggestModel.getLimit()){
|
||||
if (dtos.size() == poiSuggestModel.getLimit()) {
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(dtos));
|
||||
return mav;
|
||||
}
|
||||
List<AmapPoi> amapPois = amapPoiService.inputtips(poiSuggestModel.getCity(), poiSuggestModel.getRegion(), keywords, poiSuggestModel.getLimit(), false);
|
||||
for(AmapPoi amapPoi : amapPois){
|
||||
if(!keys.contains(amapPoi.getName())){
|
||||
for (AmapPoi amapPoi : amapPois) {
|
||||
if (!keys.contains(amapPoi.getName())) {
|
||||
UniversalDto dto = new UniversalDto();
|
||||
if(amapPoi.getCity() == null){
|
||||
if (amapPoi.getCity() == null) {
|
||||
dto.append("city", poiSuggestModel.getCity());
|
||||
}else{
|
||||
} else {
|
||||
dto.append("city", amapPoi.getCity());
|
||||
}
|
||||
if(amapPoi.getRegion() == null){
|
||||
if (amapPoi.getRegion() == null) {
|
||||
dto.append("region", poiSuggestModel.getRegion());
|
||||
}else{
|
||||
} else {
|
||||
dto.append("region", amapPoi.getRegion());
|
||||
}
|
||||
dto.append("name", amapPoi.getName());
|
||||
dto.append("address", amapPoi.getAddress());
|
||||
dtos.add(dto);
|
||||
}
|
||||
if(dtos.size() >= poiSuggestModel.getLimit()){
|
||||
if (dtos.size() >= poiSuggestModel.getLimit()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -150,16 +149,16 @@ public class PoiController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
String getLookLikeString(String orgStr, List<String> list, String extend){
|
||||
if(list == null){
|
||||
String getLookLikeString(String orgStr, List<String> list, String extend) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<String>();
|
||||
}
|
||||
list.add(extend);
|
||||
String targetStr = extend;
|
||||
double similar = 0;
|
||||
for(String item : list){
|
||||
for (String item : list) {
|
||||
double s = AddressParserUtil.getSimilarityRatio(orgStr, item);
|
||||
if(s > similar){
|
||||
if (s > similar) {
|
||||
targetStr = item;
|
||||
similar = s;
|
||||
}
|
||||
@@ -167,14 +166,14 @@ public class PoiController {
|
||||
return targetStr;
|
||||
}
|
||||
|
||||
public Object cmbTips2Action(@Valid PoiSuggestModel poiSuggestModel){
|
||||
public Object cmbTips2Action(@Valid PoiSuggestModel poiSuggestModel) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
String city = RegionData.formatCity(poiSuggestModel.getCity());
|
||||
if(city != null){
|
||||
if (city != null) {
|
||||
String region = RegionData.formatRegion(city, poiSuggestModel.getRegion());
|
||||
if(!RegionData.isRegion(city, region) && RegionData.getRegionByCity(city) != null){
|
||||
for(String r : RegionData.getRegionByCity(city)){
|
||||
if(region.startsWith(r)){
|
||||
if (!RegionData.isRegion(city, region) && RegionData.getRegionByCity(city) != null) {
|
||||
for (String r : RegionData.getRegionByCity(city)) {
|
||||
if (region.startsWith(r)) {
|
||||
region = r;
|
||||
break;
|
||||
}
|
||||
@@ -183,28 +182,28 @@ public class PoiController {
|
||||
poiSuggestModel.setCity(city);
|
||||
poiSuggestModel.setRegion(region);
|
||||
}
|
||||
if(!RegionData.isRegion(poiSuggestModel.getCity(), poiSuggestModel.getRegion()) || !RegionData.isCity(poiSuggestModel.getCity())){
|
||||
if (!RegionData.isRegion(poiSuggestModel.getCity(), poiSuggestModel.getRegion()) || !RegionData.isCity(poiSuggestModel.getCity())) {
|
||||
CbmRegion cbmRegion = cbmRegionService.findCbmRegion(poiSuggestModel.getCity(), poiSuggestModel.getRegion());
|
||||
poiSuggestModel.setCity(cbmRegion.getCity());
|
||||
poiSuggestModel.setRegion(cbmRegion.getRegion());
|
||||
}
|
||||
Address address = addressParserService.standardizeForSearch(poiSuggestModel.getCity(), poiSuggestModel.getKeywords());
|
||||
if(StringUtils.isNotBlank(address.getEffectiveAddress())){
|
||||
if (StringUtils.isNotBlank(address.getEffectiveAddress())) {
|
||||
poiSuggestModel.setKeywords(address.getEffectiveAddress());
|
||||
poiSuggestModel.setCity(address.getCity());
|
||||
poiSuggestModel.setRegion(address.getDistrict());
|
||||
}
|
||||
List<CbmAmapPoi> amapPois = amapPoiService.cmbTips(poiSuggestModel.getCity(), poiSuggestModel.getRegion(), poiSuggestModel.getKeywords());
|
||||
List<UniversalDto> dtos = new ArrayList<UniversalDto>();
|
||||
for(CbmAmapPoi poi : amapPois){
|
||||
for (CbmAmapPoi poi : amapPois) {
|
||||
UniversalDto dto = UniversalDto.newDto();
|
||||
dto.append("city", poi.getCityname());
|
||||
dto.append("region", poi.getAdname());
|
||||
dto.append("name", poi.getName());
|
||||
dto.append("address", poi.getAddress());
|
||||
if(!poi.getName().startsWith(poiSuggestModel.getKeywords()) && poi.getAlias() != null && poi.getAlias().contains(poi.getText())){
|
||||
if (!poi.getName().startsWith(poiSuggestModel.getKeywords()) && poi.getAlias() != null && poi.getAlias().contains(poi.getText())) {
|
||||
dto.append("name", poi.getText());
|
||||
}else if((poi.getAddress() != null && !poi.getAddress().startsWith(poiSuggestModel.getKeywords())) && poi.getAddrAlias() != null && poi.getAddrAlias().contains(poi.getText())){
|
||||
} else if ((poi.getAddress() != null && !poi.getAddress().startsWith(poiSuggestModel.getKeywords())) && poi.getAddrAlias() != null && poi.getAddrAlias().contains(poi.getText())) {
|
||||
dto.append("address", poi.getText());
|
||||
}
|
||||
dtos.add(dto);
|
||||
@@ -213,6 +212,62 @@ public class PoiController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* POI搜索服务
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object searchAction(AddressModel model) {
|
||||
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
if (StringUtils.isBlank(model.getLocation()) || StringUtils.isBlank(model.getCity())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("城市和经纬度为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
HttpRequest request = new HttpRequest();
|
||||
JSONObject json = null;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("city", model.getCity());
|
||||
params.put("location", model.getLocation());
|
||||
params.put("types", StringUtils.isNotBlank(model.getTypes()) ? model.getTypes() : null);
|
||||
Integer radius = model.getRadius();
|
||||
if (radius != null && radius > 0) {
|
||||
params.put("radius", radius.toString());
|
||||
}
|
||||
Integer offset = model.getOffset();
|
||||
if (offset != null && offset > 0) {
|
||||
params.put("offset", offset.toString());
|
||||
}
|
||||
Integer page = model.getPage();
|
||||
if (page != null && page > 0) {
|
||||
params.put("page", page.toString());
|
||||
}
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/poi/search", params, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/poi/search", params, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (json != null) {
|
||||
int code = json.getInt("msgCode");
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(code, msg);
|
||||
if (json.containsKey("result")) {
|
||||
basicModel.setResult(json.get("result"));
|
||||
}
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
public void setAmapPoiService(AmapPoiService amapPoiService) {
|
||||
this.amapPoiService = amapPoiService;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,14 @@ public class AddressModel extends FangjiaApiModel {
|
||||
private Integer radius;
|
||||
// 查询数量
|
||||
private Integer number;
|
||||
private Integer offset;
|
||||
// 查询页码
|
||||
private Integer pageNo;
|
||||
private Integer page;
|
||||
// 是否用于检查
|
||||
private String dataLevel;
|
||||
|
||||
private String keyword;
|
||||
private String keywords;
|
||||
//是否使用地图poi数据
|
||||
private boolean useMap;
|
||||
|
||||
@@ -46,6 +48,12 @@ public class AddressModel extends FangjiaApiModel {
|
||||
private String showFullValue;
|
||||
//是否显示涉农测试用字段值
|
||||
private String showTestValue;
|
||||
|
||||
private String lat;
|
||||
private String lng;
|
||||
|
||||
private String location;
|
||||
private String types;
|
||||
public boolean isContainsLocation() {
|
||||
return containsLocation;
|
||||
}
|
||||
@@ -239,12 +247,12 @@ public class AddressModel extends FangjiaApiModel {
|
||||
this.dataLevel = dataLevel;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
public String getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
public void setKeywords(String keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
@@ -278,4 +286,52 @@ public class AddressModel extends FangjiaApiModel {
|
||||
public void setShowTestValue(String showTestValue) {
|
||||
this.showTestValue = showTestValue;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(String lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(String types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public Integer getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(Integer offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public Integer getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Integer page) {
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,6 +3,7 @@ package com.fangjia.script.ana
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.util.CommonUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
@@ -24,7 +25,7 @@ class FindStageDistrictBatch extends BaseBatch {
|
||||
@Override
|
||||
void process(Object args) {
|
||||
CommonUtils.findAllCity().each { def city ->
|
||||
DbUtils.seaweed.find(DbUtils.buildSeaweedQuery(city), new BasicDBObject("region", 1).append("name", 1).append("master_district_name", 1).append("city", 1)).each { BasicDBObject dbo ->
|
||||
CommonDatautils.SEAWEED_COLL.find(DbUtils.buildSeaweedQuery2(city), new BasicDBObject("region", 1).append("name", 1).append("master_district_name", 1).append("city", 1)).each { BasicDBObject dbo ->
|
||||
if (dbo.name =~ STAGE_PATTERN && StringUtils.isBlank(dbo.master_district_name)) {
|
||||
def mainName = dbo.name.toString().replaceAll("([一二三四五六七八九十百千\\d]+)期\$", "")
|
||||
def query = DbUtils.buildSeaweedQuery(city, dbo.region, mainName)
|
||||
@@ -40,7 +41,6 @@ class FindStageDistrictBatch extends BaseBatch {
|
||||
println(dbo)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -9,7 +9,7 @@ import com.mongodb.DBCollection
|
||||
/**
|
||||
* 深圳公众号成交数据录入
|
||||
*/
|
||||
def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\深圳2024年3月份二手房成交数据汇总.xls", 0, 1)
|
||||
def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\20240619--深圳成交数据.xlsx", 0, 1)
|
||||
def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017";
|
||||
DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl)
|
||||
|
||||
@@ -72,19 +72,21 @@ for(def d : datas){
|
||||
|
||||
}
|
||||
|
||||
map.area = d['F'].toString().toDouble()
|
||||
map.total_price = (int)(d['G'].toString().toDouble().toInteger()*10000)
|
||||
map.avg_price = (int)(d['H'].toString().toDouble())
|
||||
map.area = d['F'].replace("平","").toString().toDouble()
|
||||
map.total_price = (int)(d['G'].replace("万","").toString().toDouble().toInteger()*10000)
|
||||
map.avg_price = (int)(d['H'].replace("元/平","").toString().toDouble())
|
||||
if(d['I']){
|
||||
map.sell_price = (int)(d['I'].toString().toDouble()*10000)
|
||||
map.sell_price = (int)(d['I'].replace("万","").toString().toDouble()*10000)
|
||||
}
|
||||
|
||||
map.trade_date = d['J']
|
||||
// def trade_date = d['J']
|
||||
// if(trade_date){
|
||||
// map.trade_date = DateUtils.parseFromTightByPattern(trade_date,'yyyy/MM/dd')
|
||||
// }else{
|
||||
def trade_date1 = DateUtils.getRandomDate("2024-03-01", "2024-03-31")
|
||||
map.trade_date = DateUtils.parseFromTightByPattern(trade_date1, "yyyy-MM-dd")
|
||||
// }
|
||||
// else{
|
||||
// def trade_date1 = DateUtils.getRandomDate("2024-03-01", "2024-03-31")
|
||||
// map.trade_date = DateUtils.parseFromTightByPattern(trade_date1, "yyyy-MM-dd")
|
||||
// }
|
||||
|
||||
map.source = "深房家族"
|
||||
|
||||
+26
-17
@@ -35,7 +35,7 @@ import java.util.regex.Pattern
|
||||
@BatchOwner(Watcher.GaoJuan)
|
||||
class BigdataDealBatch extends BaseBatch{
|
||||
|
||||
def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -24, "yyyyMM"));
|
||||
def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM"));
|
||||
def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM"));
|
||||
|
||||
def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMMdd"), -1, "yyyyMMdd"));
|
||||
@@ -62,20 +62,20 @@ class BigdataDealBatch extends BaseBatch{
|
||||
@Override
|
||||
public void process(Object args) {
|
||||
|
||||
def date = DateUtils.parseFromTightByPattern("2024-5-21", "yyyy-MM-dd")
|
||||
def objectId = dateToObjectId(date)
|
||||
println objectId
|
||||
// def date = DateUtils.parseFromTightByPattern("2024-5-21", "yyyy-MM-dd")
|
||||
// def objectId = dateToObjectId(date)
|
||||
// println objectId
|
||||
|
||||
//664a22000000000000000000 5-20
|
||||
//664b73800000000000000000 5-21
|
||||
def citys = CcbCommonUtils.getRunningCitys(args)
|
||||
//
|
||||
// println "curDate:"+curDate
|
||||
// def allCitys = CommonDatautils.findAllCity()
|
||||
// for(def city : allCitys){
|
||||
// addDealPriceMatch(city);
|
||||
// }
|
||||
// updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月
|
||||
|
||||
println "curDate:"+curDate
|
||||
def allCitys = CommonDatautils.findAllCity()
|
||||
for(def city : allCitys){
|
||||
addDealPriceMatch(city);
|
||||
}
|
||||
updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月
|
||||
|
||||
|
||||
def rows = []
|
||||
@@ -189,7 +189,7 @@ class BigdataDealBatch extends BaseBatch{
|
||||
})
|
||||
}
|
||||
println "查询完成......."
|
||||
latch.await(5, TimeUnit.MINUTES);
|
||||
latch.await();
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -726,15 +726,24 @@ class BigdataDealBatch extends BaseBatch{
|
||||
t.name = t.name +"商住楼"
|
||||
}
|
||||
}
|
||||
rMap = SeaweedDataMatchProcess.doMatch(t.city, region, t.name, null);
|
||||
if(!rMap && t.address){
|
||||
def flag = t.address.matches('^[\u4e00-\u9fa5]+?(路|大道|街|巷).+[弄号]$')
|
||||
def flag = false
|
||||
def address = null
|
||||
if(t.address){
|
||||
flag = t.address.matches('^[\u4e00-\u9fa5]+?(路|大道|街|巷).+[弄号]$')
|
||||
if(flag){
|
||||
rMap = SeaweedDataMatchProcess.doMatch(t.city, region, null, t.address);
|
||||
address = t.address
|
||||
}
|
||||
}
|
||||
|
||||
rMap = SeaweedDataMatchProcess.doMatch(t.city, region, t.name, address);
|
||||
if(!rMap && !t.name.toString().endsWith("小区")){
|
||||
rMap = SeaweedDataMatchProcess.doMatch(t.city, region, t.name+"小区", address);
|
||||
}
|
||||
|
||||
if(rMap && rMap.region==region){
|
||||
CcbCommonUtils.updateDealPrice(t._id, rMap.city, rMap.region, rMap.name, rMap.id)
|
||||
}else if(rMap && rMap.address && address && rMap.region!=region && address.contains(rMap.address)){
|
||||
CcbCommonUtils.updateDealPrice(t._id, rMap.city, rMap.region, rMap.name, rMap.id)
|
||||
}else {
|
||||
if (rMap) {
|
||||
println "区域不同"
|
||||
@@ -752,7 +761,7 @@ class BigdataDealBatch extends BaseBatch{
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
)
|
||||
}
|
||||
latch.await()
|
||||
println city +" "+trades.size()+" "+new Date().toString()
|
||||
|
||||
+18
-4
@@ -7,16 +7,20 @@ import com.fangjia.script.lixue.util.DBUtils
|
||||
import com.fangjia.script.util.DataUtil
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.google.common.hash.BloomFilter
|
||||
import com.google.common.hash.Funnels
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
import com.rabbitmq.client.impl.AMQImpl
|
||||
import groovy.sql.Sql
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
class CcbCommonUtils {
|
||||
|
||||
|
||||
public static def citys_fjw_all = ["深圳","上海","长春","扬州","北京","重庆","天津","成都","沈阳","大连","安庆","西宁","日照","武汉","西安","乌鲁木齐","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台", "徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水","潍坊","临沂","邯郸","济宁","威海","绵阳","梅州","平顶山","江门","赣州","泰安","襄阳","南阳","桂林","聊城","临汾","德州","商丘","衡阳","宿迁","包头","渭南","咸阳","许昌","滨州","邢台","南充","安阳","新乡","枣庄","滁州","龙岩","宝鸡","信阳","运城","衡水","东营","晋中","孝感","长治","阜阳","韶关","菏泽","德阳","宁德","荆州","乐山","驻马店","南平","汉中","榆林","宜春","鞍山","开封","周口","绥化","湘潭","黄冈","承德","焦作","牡丹江","莆田","上饶","眉山","齐齐哈尔","郴州","营口","蚌埠","大庆","赤峰","河源","吕梁","遂宁","漯河","三明","茂名","濮阳","曲靖","平凉","鄂尔多斯","十堰","吉安","黄石","佳木斯","三门峡","揭阳","忻州","通辽","泸州","六安","潮州","衢州","淮南","荆门","永州","呼伦贝尔","葫芦岛","丹东","延边","宣城","宜宾","庆阳","晋城","阳江","宿州","延安","咸宁","怀化","黄山","舟山","汕尾","盘锦","朝阳","丽水","抚州","铁岭","红河","陇南","广安","抚顺","自贡","达州","玉林","玉溪","白银","亳州","邵阳","广元","昌吉","益阳","张掖","娄底","阳泉","天水","随州","朔州","大理","通化","楚雄","巴彦淖尔","乌兰察布","新余","景德镇","松原","辽阳","阜新","酒泉","黔南","淮北","四平","梧州","黔东南","巴中","鹤壁","鸡西","内江","钦州","池州","仙桃","恩施","本溪","资阳","六盘水","百色","白城","临夏","伊犁","贵港","白山","双鸭山","吴忠","鄂州","丽江","安康","毕节","云浮","巴音郭楞","安顺","阿克苏","黑河","铜陵","雅安","石嘴山","萍乡","鹤岗","锡林郭勒盟","铜仁","防城港","喀什","兴安盟","河池","铜川","普洱","保山","凉山州","鹰潭","定西","伊春","中卫","黔西南","商洛","乌海","武威","海西州","来宾","昭通","湘西","哈密","张家界","西双版纳州","七台河","固原","攀枝花","德宏州","崇左","辽源","嘉峪关","克拉玛依","临沧","潜江","贺州","天门","海东","塔城","儋州","金昌","博尔塔拉","吐鲁番","大兴安岭","阿勒泰","和田","迪庆州","日喀则","林芝","阿坝州","阿拉善盟","阿里","昌都","甘南","甘孜州","果洛州","海北州","海南州","黄南州","克孜勒苏","那曲","怒江州","三沙","山南","神农架","文山州","玉树州","白沙","北屯","昌江","澄迈","定安","东方","济源","可克达拉","昆玉","乐东","临高","琼海","琼中","石河子","双河","铁门关","图木舒克","屯昌","万宁","五家渠","五指山","阿拉尔"]
|
||||
public static def citys_fjw_all = ["上海","长春","扬州","北京","重庆","天津","成都","深圳","沈阳","大连","安庆","西宁","日照","武汉","西安","乌鲁木齐","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台", "徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水","潍坊","临沂","邯郸","济宁","威海","绵阳","梅州","平顶山","江门","赣州","泰安","襄阳","南阳","桂林","聊城","临汾","德州","商丘","衡阳","宿迁","包头","渭南","咸阳","许昌","滨州","邢台","南充","安阳","新乡","枣庄","滁州","龙岩","宝鸡","信阳","运城","衡水","东营","晋中","孝感","长治","阜阳","韶关","菏泽","德阳","宁德","荆州","乐山","驻马店","南平","汉中","榆林","宜春","鞍山","开封","周口","绥化","湘潭","黄冈","承德","焦作","牡丹江","莆田","上饶","眉山","齐齐哈尔","郴州","营口","蚌埠","大庆","赤峰","河源","吕梁","遂宁","漯河","三明","茂名","濮阳","曲靖","平凉","鄂尔多斯","十堰","吉安","黄石","佳木斯","三门峡","揭阳","忻州","通辽","泸州","六安","潮州","衢州","淮南","荆门","永州","呼伦贝尔","葫芦岛","丹东","延边","宣城","宜宾","庆阳","晋城","阳江","宿州","延安","咸宁","怀化","黄山","舟山","汕尾","盘锦","朝阳","丽水","抚州","铁岭","红河","陇南","广安","抚顺","自贡","达州","玉林","玉溪","白银","亳州","邵阳","广元","昌吉","益阳","张掖","娄底","阳泉","天水","随州","朔州","大理","通化","楚雄","巴彦淖尔","乌兰察布","新余","景德镇","松原","辽阳","阜新","酒泉","黔南","淮北","四平","梧州","黔东南","巴中","鹤壁","鸡西","内江","钦州","池州","仙桃","恩施","本溪","资阳","六盘水","百色","白城","临夏","伊犁","贵港","白山","双鸭山","吴忠","鄂州","丽江","安康","毕节","云浮","巴音郭楞","安顺","阿克苏","黑河","铜陵","雅安","石嘴山","萍乡","鹤岗","锡林郭勒盟","铜仁","防城港","喀什","兴安盟","河池","铜川","普洱","保山","凉山州","鹰潭","定西","伊春","中卫","黔西南","商洛","乌海","武威","海西州","来宾","昭通","湘西","哈密","张家界","西双版纳州","七台河","固原","攀枝花","德宏州","崇左","辽源","嘉峪关","克拉玛依","临沧","潜江","贺州","天门","海东","塔城","儋州","金昌","博尔塔拉","吐鲁番","大兴安岭","阿勒泰","和田","迪庆州","日喀则","林芝","阿坝州","阿拉善盟","阿里","昌都","甘南","甘孜州","果洛州","海北州","海南州","黄南州","克孜勒苏","那曲","怒江州","三沙","山南","神农架","文山州","玉树州","白沙","北屯","昌江","澄迈","定安","东方","济源","可克达拉","昆玉","乐东","临高","琼海","琼中","石河子","双河","铁门关","图木舒克","屯昌","万宁","五家渠","五指山","阿拉尔"]
|
||||
|
||||
public static def citys_all = ["乌鲁木齐","上海","长春","扬州","北京","重庆","天津","成都","沈阳","大连","安庆","西宁","日照","武汉","西安","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台","徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","深圳","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水","潍坊","临沂","邯郸","济宁","威海","绵阳","梅州","平顶山","江门","赣州","泰安","襄阳","南阳","桂林","聊城","临汾","德州","商丘","衡阳","宿迁","包头","渭南","咸阳","许昌","滨州","邢台","南充","安阳","新乡","枣庄","滁州","龙岩","宝鸡","信阳","运城","衡水","东营","晋中","孝感","长治","阜阳","韶关","菏泽","德阳","宁德","荆州","乐山","驻马店","南平","汉中","榆林","宜春","鞍山","开封","周口","绥化","湘潭","黄冈","承德","焦作","牡丹江","莆田","上饶","眉山","齐齐哈尔","郴州","营口","蚌埠","大庆","赤峰","河源","吕梁","遂宁","漯河","三明","茂名","濮阳","曲靖","平凉","鄂尔多斯","十堰","吉安","黄石","佳木斯","三门峡","揭阳","忻州","通辽","泸州","六安","潮州","衢州","淮南","荆门","永州","呼伦贝尔","葫芦岛","丹东","延边","宣城","宜宾","庆阳","晋城","阳江","宿州","延安","咸宁","怀化","黄山","舟山","汕尾","盘锦","朝阳","丽水","抚州","铁岭","红河","陇南","广安","抚顺","自贡","达州","玉林","玉溪","白银","亳州","邵阳","广元","昌吉","益阳","张掖","娄底","阳泉","天水","随州","朔州","大理","通化","楚雄","巴彦淖尔","乌兰察布","新余","景德镇","松原","辽阳","阜新","酒泉","黔南","淮北","四平","梧州","黔东南","巴中","鹤壁","鸡西","内江","钦州","池州","仙桃","恩施","本溪","资阳","六盘水","百色","白城","临夏","伊犁","贵港","白山","双鸭山","吴忠","鄂州","丽江","安康","毕节","云浮","巴音郭楞","安顺","阿克苏","黑河","铜陵","雅安","石嘴山","萍乡","鹤岗","锡林郭勒盟","铜仁","防城港","喀什","兴安盟","河池","铜川","普洱","保山","凉山州","鹰潭","定西","伊春","中卫","黔西南","商洛","乌海","武威","海西州","来宾","昭通","湘西","哈密","张家界","西双版纳州","七台河","固原","攀枝花","德宏州","崇左","辽源","嘉峪关","克拉玛依","临沧","潜江","贺州","天门","海东","塔城","儋州","金昌","博尔塔拉","吐鲁番","大兴安岭","阿勒泰","和田","迪庆州","日喀则","林芝"]
|
||||
public static def citys_92 = [ "上海","扬州","北京","重庆","天津","成都","沈阳","大连","安庆","西宁","日照","长春","武汉","西安","苏州","广州","南京","青岛","济南","宁波","长沙","石家庄","佛山","嘉兴","银川","南通","廊坊","中山","郑州","哈尔滨","烟台","徐州","绍兴","厦门","昆明","南昌","贵阳","珠海","东莞","镇江","洛阳","温州","兰州","福州","惠州","呼和浩特","常州","唐山","淮安","湖州","九江","太原","北海","株洲","淄博","盐城","乌鲁木齐","海口","南宁","常德","台州","金华","吉林","岳阳","柳州","清远","湛江","张家口","保定","深圳","杭州","合肥","无锡","泉州","遵义","肇庆","漳州","宜昌","芜湖","泰州","汕头","三亚","秦皇岛","马鞍山","连云港","沧州","拉萨","锦州","大同","文昌","保亭","陵水"]
|
||||
@@ -440,9 +444,9 @@ class CcbCommonUtils {
|
||||
q.put("cat", cat);
|
||||
q.put("city", city);
|
||||
// q.put("c_date", new BasicDBObject('$lt', DateUtils.parseFromTightYYYYMMDD("2023-05-01")))//因5月1日新增过多,所以暂且先去掉 此批数据改为name_cat=13
|
||||
// q.put("name","鸿运大院")
|
||||
// q.put("name","同心花园")
|
||||
// q.put("name_cat", 0);
|
||||
// q.put("estate_type2", new BasicDBObject('$in', ["普通住宅","商住"]))
|
||||
// q.put("name", new BasicDBObject('$in', ["中信泰富又一城一期","中信泰富又一城"]))
|
||||
|
||||
DBObject keys = new BasicDBObject();
|
||||
if(fields){
|
||||
@@ -634,7 +638,8 @@ class CcbCommonUtils {
|
||||
q.put("city", city)
|
||||
q.put("trade_date", new BasicDBObject('$gte', startDate))
|
||||
q.put("match_id", new BasicDBObject('$exists', false))
|
||||
// q.put("district_name","中海寰宇天下")
|
||||
// q.put("district_name","新明胡同")
|
||||
// q.put("address","桂苑大道135号")
|
||||
def dbcursor = DEAL_PRICE_COLL.find(q)
|
||||
def total = dbcursor.count()
|
||||
def rets = new HashSet()
|
||||
@@ -683,6 +688,15 @@ class CcbCommonUtils {
|
||||
pgsqlInstance.executeUpdate(sql2)
|
||||
}
|
||||
|
||||
public static def findGuiDingIdsByCity(){
|
||||
// 创建布隆过滤器对象
|
||||
BloomFilter<CharSequence> filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001);
|
||||
pgsqlInstance.eachRow("SELECT gujia_fsid FROM base.t0831_guided_price_gj_h",{it->
|
||||
filter.put(it.gujia_fsid)
|
||||
});
|
||||
return filter
|
||||
}
|
||||
|
||||
|
||||
public static def findDistGovPrice(def city){
|
||||
def ids = []
|
||||
|
||||
+1
-1
@@ -389,7 +389,7 @@ class DealPriceDataProcess {
|
||||
def deleteThirdPartyData(){
|
||||
// ,"陵水","塔城","保亭","长沙","苏州","南昌","沧州","文昌","衡水"
|
||||
// def citys = ["310000","440100","500000","410100","430100","330100","340100","320100","370200","320500","120000","442000","320300","350200","360100","320400","210200","530100","469005","469028","469029","230700","610700","533400","650400","511100","131100"]//CcbCommonUtils.citys_all
|
||||
def citys = ["上海","广州"]//CcbCommonUtils.citys_all
|
||||
def citys = CcbCommonUtils.citys_all
|
||||
def month = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM"));//上个月日期
|
||||
def rows = []
|
||||
def cityCodeDatas = CcbCommonUtils.findCityCodeValue()
|
||||
|
||||
+16
-3
@@ -47,16 +47,22 @@ class GuiDingPriceBatch extends BaseBatch{
|
||||
def rows = []
|
||||
|
||||
CcbCommonUtils.deleteGuidedPrice(curDate)
|
||||
|
||||
def priceIdsfilter = CcbCommonUtils.findGuiDingIdsByCity()
|
||||
for (def city : citys) {
|
||||
def cityCodeDatas = CcbCommonUtils.findCityCodeValue()
|
||||
def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city)
|
||||
|
||||
//添加自己库中的人工指导价
|
||||
def prices = CcbCommonUtils.findPersonPrice(city, "2024-05-24", "2024-06-08")
|
||||
// def prices = CcbCommonUtils.findPersonPrice(city, "2024-05-24", "2024-06-27")
|
||||
// def prices = CcbCommonUtils.findPersonPrice(city, "2022-01-01", "2022-11-22")
|
||||
//近3个月人工指导价
|
||||
def end = DateUtils.add(DateUtils.formatDateByPattern(new Date(),"yyyy-MM-dd"), 1)
|
||||
def start = DateUtils.add(DateUtils.formatDateByPattern(new Date(),"yyyy-MM-dd"), -90)
|
||||
def prices = CcbCommonUtils.findPersonPrice(city, start, end)
|
||||
if(prices){
|
||||
def distMap = getDistrictMap(city)
|
||||
def rets = createCityDatas(cityCodeDatas, distCodeMap, distMap, prices)
|
||||
def rets = createCityDatas(cityCodeDatas, distCodeMap, distMap, prices, priceIdsfilter)
|
||||
rows.addAll(rets)
|
||||
println city + " " + rets.size()
|
||||
}
|
||||
@@ -142,11 +148,18 @@ class GuiDingPriceBatch extends BaseBatch{
|
||||
return obj
|
||||
}
|
||||
|
||||
def createCityDatas(cityCodeDatas, distCodeMap, distMap, prices){
|
||||
def createCityDatas(cityCodeDatas, distCodeMap, distMap, prices, priceIdsfilter){
|
||||
def rets = []
|
||||
if(prices){
|
||||
for(def ps : prices){
|
||||
|
||||
def dist = distMap.get(ps.region+"##"+ps.name)
|
||||
|
||||
if(priceIdsfilter.mightContain(ps._id.toString())){
|
||||
println ps._id.toString() +ps.region+"##"+ps.name+" 已存在"
|
||||
continue
|
||||
}
|
||||
|
||||
if(dist){
|
||||
def ret = []
|
||||
def areaData = distCodeMap.get(dist.region)
|
||||
|
||||
+41
-7
@@ -1289,19 +1289,20 @@ def findAvgPrice(def commid, def pgsqlInstance, def cityid){
|
||||
|
||||
|
||||
|
||||
def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240607人工指导价.xlsx"
|
||||
def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240626人工指导价.xlsx"
|
||||
|
||||
ExcelUtils.multiThreadingModify(fileName, {d->
|
||||
if(d['J']){
|
||||
// def region = RegionData.formatRegion(d['B'], d['C'])
|
||||
// def region = RegionData.formatRegion(d['A'], d['J'])
|
||||
// if(region){
|
||||
// def dist = CommonDatautils.findDistrict(d['B'], region, d['E'], "district")
|
||||
// def dist = CommonDatautils.findDistrict(d['A'], region, d['K'], "district")
|
||||
// if(dist){
|
||||
// d['G'] = dist.region
|
||||
// d['H'] = dist._id.toString()
|
||||
// d['B'] = dist.region
|
||||
// d['C'] = dist.name
|
||||
// d['L'] = dist.status-dist.name_cat
|
||||
// }
|
||||
// }
|
||||
if(!d['A'] && d['J'] instanceof String){
|
||||
// if(d['J'] instanceof String){
|
||||
def dist = CommonDatautils.findDistrictById(d['J'])
|
||||
if(dist){
|
||||
d['A'] = dist.city
|
||||
@@ -1313,11 +1314,24 @@ ExcelUtils.multiThreadingModify(fileName, {d->
|
||||
|
||||
// d['H'] = dist.name
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
},0)
|
||||
|
||||
|
||||
//def file = "D:\\数据\\建行\\房产估值\\指导价\\5城价格翻新6-21.xlsx"
|
||||
//ExcelUtils.multiThreadingModify(file, { d ->
|
||||
// if(d['A']){
|
||||
// def dist = CommonDatautils.findDistrictById(d['A'])
|
||||
// if(dist){
|
||||
// d['C'] = dist.city
|
||||
// d['D'] = dist.region
|
||||
// d['E'] = dist.name
|
||||
// def random = RandomUtil.random(-300,50)
|
||||
// d['F'] = random + d['B']
|
||||
// }
|
||||
// }
|
||||
//})
|
||||
//def filePath = "D:\\数据\\建行\\房产估值\\小区\\估家独家数据打标签.xlsx"
|
||||
//ExcelUtils.multiThreadingModify(filePath, { d ->
|
||||
// if(d['B']){
|
||||
@@ -1339,6 +1353,23 @@ ExcelUtils.multiThreadingModify(fileName, {d->
|
||||
//})
|
||||
|
||||
|
||||
//def filePath = "D:\\数据\\建行\\房产估值\\指导价\\大庆删除小区.xlsx"
|
||||
//ExcelUtils.modify(filePath, { d ->
|
||||
// if(d['A']){
|
||||
//
|
||||
// def obj = CommonDatautils.findDistrictById(d['A'])
|
||||
// if(obj){
|
||||
//
|
||||
// def data = new BasicDBObject()
|
||||
// data.put("status", 1)
|
||||
// data.put("m_date", new Date())
|
||||
// DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])), new BasicDBObject('$set', data))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//})
|
||||
|
||||
|
||||
//def fileName = "D:\\数据\\建行\\房产估值\\指导价\\2024-04-08修改人工指导价.xlsx"
|
||||
//ExcelUtils.multiThreadingModify(fileName, { d ->
|
||||
// if(d['B'] && !d['D']){
|
||||
@@ -1439,6 +1470,9 @@ def findPgDealPrice(c, pgsqlInstance, startDate){
|
||||
return count
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//citys = CcbCommonUtils.citys_all
|
||||
//def cityCodeDataMap = CcbCommonUtils.findCityCodeValue()
|
||||
////def dates = ["2022-07-01","2022-08-01","2022-09-01","2022-10-01","2022-11-01","2022-12-01","2023-01-01","2023-02-01","2023-03-01","2023-04-01","2023-05-01","2023-06-01"]
|
||||
|
||||
+1
-9
@@ -47,15 +47,7 @@ class ThirdPartyPriceBatch extends BaseBatch {
|
||||
@Override
|
||||
public void process(Object args) {
|
||||
|
||||
// def gocPrices = CcbCommonUtils.findDistGovPrice("深圳")
|
||||
// def sql = "delete from base.t0831_bigdata_third_party_price_gj_h where gujiabds_avprc_dt_val=202303 and gujia_bds_id=?"
|
||||
// pgsqlInstance.withBatch(500, sql){ ps->
|
||||
// for(def id : gocPrices){
|
||||
// ps.addBatch(id)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
def citys = ["上海","广州"]//CcbCommonUtils.getRunningCitys(args)
|
||||
def citys = CcbCommonUtils.getRunningCitys(args)
|
||||
def rows = []
|
||||
def index = 0
|
||||
def weekend = DateUtils.getFirstDayOfWeek(DateUtils.parseFromTightByPattern(sDate+"15", "yyyyMMdd"))
|
||||
|
||||
+4
-4
@@ -40,8 +40,8 @@ class TradeStatLog {
|
||||
|
||||
static main(args) {
|
||||
def task = new TradeStatLog()
|
||||
task.run()//统计最近3个月抓取的成交数据量
|
||||
// task.exportTrade()//导出未入库成交
|
||||
// task.run()//统计最近3个月抓取的成交数据量
|
||||
task.exportTrade()//导出未入库成交
|
||||
// task.thirdPartyStat()
|
||||
// println Calendar.getInstance().get(Calendar.YEAR)
|
||||
// task.averageStat()
|
||||
@@ -499,8 +499,8 @@ class TradeStatLog {
|
||||
def headers = ["ID", "城市", "区域", "名称", "来源","价格", "面积","地址", "成交时间","过滤原因"]
|
||||
def rets = []
|
||||
rets << headers
|
||||
def startDate = "2023-08-01"
|
||||
def endDate = "2023-10-01"
|
||||
def startDate = "2024-04-01"
|
||||
def endDate = "2024-06-01"
|
||||
for(def city : citys){
|
||||
|
||||
def trades = findTradesDetail(city, DateUtils.parseFromTightByPattern(startDate,"yyyy-MM-dd"), DateUtils.parseFromTightByPattern(endDate,"yyyy-MM-dd"))
|
||||
|
||||
+36
-35
@@ -1846,39 +1846,6 @@ class CommonDatautils {
|
||||
}
|
||||
return priceMap;
|
||||
}
|
||||
|
||||
|
||||
public static def queryDistrictPrice(city, region, name, weekend, cat){
|
||||
DBObject queryCondition = new BasicDBObject()
|
||||
queryCondition.put("city", city);
|
||||
queryCondition.put("region", region);
|
||||
queryCondition.put("district_name", name);
|
||||
queryCondition.put("weekend", weekend);
|
||||
|
||||
if(cat == "district"){
|
||||
BasicDBObject queryObj = new BasicDBObject();
|
||||
queryObj.putAt(QueryOperators.IN, ["小区","别墅"]);
|
||||
queryCondition.put("estate_type", queryObj);
|
||||
}else if(cat == "office"){
|
||||
queryCondition.put("estate_type", "写字楼");
|
||||
}else if(cat == "shop"){
|
||||
queryCondition.put("estate_type", "商铺");
|
||||
}
|
||||
|
||||
|
||||
DBCursor cur = DIST_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", -1))
|
||||
cur.setOptions(Bytes.QUERYOPTION_NOTIMEOUT)
|
||||
def price = 0;
|
||||
while(cur.hasNext()) {
|
||||
DBObject dbo = cur.next()
|
||||
price = dbo.get("avg_price");
|
||||
if(price){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
public static def queryFirstDistrictPrice(city, region, name){
|
||||
@@ -1917,6 +1884,39 @@ class CommonDatautils {
|
||||
}
|
||||
|
||||
|
||||
public static def queryDistrictPrice(city, region, name, weekend, cat){
|
||||
DBObject queryCondition = new BasicDBObject()
|
||||
queryCondition.put("city", city);
|
||||
queryCondition.put("region", region);
|
||||
queryCondition.put("district_name", name);
|
||||
queryCondition.put("weekend", weekend);
|
||||
|
||||
if(cat == "district"){
|
||||
BasicDBObject queryObj = new BasicDBObject();
|
||||
queryObj.putAt(QueryOperators.IN, ["小区","别墅"]);
|
||||
queryCondition.put("estate_type", queryObj);
|
||||
}else if(cat == "office"){
|
||||
queryCondition.put("estate_type", "写字楼");
|
||||
}else if(cat == "shop"){
|
||||
queryCondition.put("estate_type", "商铺");
|
||||
}
|
||||
|
||||
|
||||
DBCursor cur = DIST_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", -1))
|
||||
cur.setOptions(Bytes.QUERYOPTION_NOTIMEOUT)
|
||||
def price = 0;
|
||||
while(cur.hasNext()) {
|
||||
DBObject dbo = cur.next()
|
||||
price = dbo.get("avg_price");
|
||||
if(price){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
public static def queryDistrictPrice(city, region, name){
|
||||
DBObject queryCondition = new BasicDBObject()
|
||||
queryCondition.put("city", city);
|
||||
@@ -4679,7 +4679,8 @@ class CommonDatautils {
|
||||
|
||||
def q = new BasicDBObject()
|
||||
q.put("type","乡镇街道")
|
||||
q.put("province",new BasicDBObject('$in', ['福建省','重庆市']))
|
||||
// q.put("province",new BasicDBObject('$in', ['浙江省','江苏省','山东省']))
|
||||
// q.put("city","芜湖市")
|
||||
|
||||
def keys = new BasicDBObject()
|
||||
keys.put("province",1)
|
||||
@@ -4688,7 +4689,7 @@ class CommonDatautils {
|
||||
keys.put("street",1)
|
||||
keys.put("shape",1)
|
||||
keys.put("alias",1)
|
||||
def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000)
|
||||
def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT)
|
||||
def townMap = [:]
|
||||
for(def d : dbcursor){
|
||||
def key = d.city+"#"+d.district
|
||||
|
||||
@@ -13,12 +13,15 @@ import net.sf.json.groovy.JsonSlurper
|
||||
import org.apache.commons.lang.StringUtils
|
||||
|
||||
class OpenApiUtils {
|
||||
static def matchDistrict(def city, def address, def suggestDistrict, def preciseLevelflag){
|
||||
static def matchDistrict(def city, def address, def suggestDistrict, def preciseLevelflag, def suggestName){
|
||||
address = address.replace("£¨","(").replace("£©",")").replace(" ","").replace("#","").replace("<","").replace(">","").replace("%","").replace("\"","")
|
||||
def url = "http://open.fangjia.com/address/matchV2?city="+city+"&address="+address+"&suggestDistrict="+suggestDistrict+"&token=F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB&category=district&__refresh_cache=1"
|
||||
if(preciseLevelflag){
|
||||
url = url +"&preciseLevel=strict"
|
||||
}
|
||||
if(suggestName){
|
||||
url = url +"&suggestName="+suggestName
|
||||
}
|
||||
String content = new HttpRequest().get(url, "utf-8");
|
||||
def rMap = [:]
|
||||
if(content){
|
||||
|
||||
+17
-16
@@ -32,7 +32,7 @@ class DevProcess {
|
||||
def task = new DevProcess();
|
||||
// task.run()
|
||||
// task.parseCityAndDist()
|
||||
task.devSplitRoad()
|
||||
task.devSplitRoad()
|
||||
// task.devNameSplitRoad()
|
||||
// task.addFlag()
|
||||
// task.matchDev()
|
||||
@@ -644,16 +644,16 @@ class DevProcess {
|
||||
|
||||
|
||||
def matchDevAndAddAddress(){
|
||||
ExcelUtils.modify("D:\\数据\\数据建设\\浙江-湖州路正常(2.6+15万修正).xlsx",{d->
|
||||
if(d['R']){
|
||||
ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\新跑省份\\福建重庆去重后地址.xlsx",{d->
|
||||
if(d['E']){
|
||||
def q = new BasicDBObject()
|
||||
q.put("name", d['R'])
|
||||
q.put("name", d['E'])
|
||||
def obj = development_zone_CONN.findOne(q)
|
||||
if(obj){
|
||||
|
||||
d['P'] = obj._id.toString()
|
||||
d['Q'] = obj.name
|
||||
def address = d['L']+d['M']
|
||||
d['F'] = obj._id.toString()
|
||||
d['G'] = obj.name
|
||||
def address = d['D']
|
||||
q.put("address", address)
|
||||
// def street = d['G']
|
||||
// q.put("township", street)
|
||||
@@ -671,6 +671,7 @@ class DevProcess {
|
||||
udata.put("name",obj.name)
|
||||
udata.put("type", "µØÖ·")
|
||||
udata.put("address",address)
|
||||
udata.put("c_date", new Date())
|
||||
// udata.put("type", "ÏçÕò½ÖµÀ")
|
||||
// udata.put("township", street)
|
||||
DEV_MAPPING_CONN.save(udata)
|
||||
@@ -684,14 +685,14 @@ class DevProcess {
|
||||
|
||||
|
||||
def matchDevTownship(){
|
||||
ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\区域匹配开发区.xlsx",{d->
|
||||
if(d['C']){
|
||||
ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\新跑省份\\福建重庆去重后地址.xlsx",{d->
|
||||
if(d['D']){
|
||||
def q = new BasicDBObject()
|
||||
q.put("name", d['C'])
|
||||
q.put("name", d['D'])
|
||||
def obj = development_zone_CONN.findOne(q)
|
||||
if(obj){
|
||||
d['E'] = obj._id.toString()
|
||||
def street = d['D']
|
||||
d['F'] = obj._id.toString()
|
||||
def street = d['E']
|
||||
q.put("township", street)
|
||||
def sameObj = DEV_MAPPING_CONN.findOne(q)
|
||||
if(!sameObj){
|
||||
@@ -705,11 +706,11 @@ class DevProcess {
|
||||
}
|
||||
|
||||
udata.put("name",obj.name)
|
||||
// udata.put("type", "乡镇街道")
|
||||
// udata.put("township", street)
|
||||
udata.put("type", "乡镇街道")
|
||||
udata.put("township", street)
|
||||
|
||||
udata.put("type", "区域")
|
||||
udata.put("dev_district", street)
|
||||
// udata.put("type", "区域")
|
||||
// udata.put("dev_district", street)
|
||||
udata.put("c_date",new Date())
|
||||
DEV_MAPPING_CONN.save(udata)
|
||||
println obj.name +" "+street
|
||||
|
||||
+4
-3
@@ -137,9 +137,10 @@ class GXDdistrictMatch {
|
||||
}
|
||||
|
||||
def runMatch(){
|
||||
def fileName = "D:\\数据\\福州\\福州贝壳数据.xlsx"//11城重新匹配.xlsx
|
||||
def city = "福州"
|
||||
ExcelUtils.modify(fileName, { d ->
|
||||
def fileName = "D:\\数据\\福州\\建行测试匹配.xlsx"//11城重新匹配.xlsx 福州贝壳数据.xlsx
|
||||
|
||||
ExcelUtils.multiThreadingModify(fileName, { d ->
|
||||
def city = d['A']
|
||||
println d['C']
|
||||
if(d['B'] && d['A']){
|
||||
def region = RegionData.formatRegion(city, d['B'])
|
||||
|
||||
+36
-14
@@ -38,17 +38,18 @@ class PoiLocation {
|
||||
task.run();
|
||||
}
|
||||
def run(){
|
||||
def citys = ["莆田市","宁德市","三明市","龙岩市","南平市","漳州市","福州市","厦门市","泉州市","重庆市"]
|
||||
def citys = ["芜湖市","重庆市","杭州市","泉州市","东莞市","福州市","厦门市","佛山市","天津市","武汉市","宁波市","郑州市","长沙市","青岛市","上海市","西安市","温州市","无锡市","南京市","湖州市","合肥市","临沂市","石家庄市","昆明市","金华市","保定市","成都市","济南市","北京市","沈阳市","潍坊市","广州市","惠州市","嘉兴市","赣州市","苏州市","南通市","南宁市","台州市","南阳市","徐州市","长春市","深圳市","哈尔滨市","漳州市","中山市","常州市","烟台市","大连市","邯郸市","济宁市","盐城市","绍兴市","唐山市","洛阳市","阜阳市","菏泽市","贵阳市","沧州市","遵义市","莆田市","南昌市","商丘市","周口市","邢台市","江门市","衡阳市","邵阳市","信阳市","廊坊市","扬州市","泰州市","新乡市","太原市","德州市","淄博市","宁德市","绵阳市","汕头市","聊城市","淮安市","驻马店市","黄冈市","宿迁市","三明市","六安市","龙岩市","桂林市","岳阳市","南平市","揭阳市","上饶市","九江市","南充市","连云港市","襄阳市","泰安市","常德市","郴州市","安阳市","安庆市","湛江市","永州市","茂名市","曲靖市","宜宾市","肇庆市","宿州市","兰州市","运城市","镇江市","滁州市","威海市","梅州市","宜春市","清远市","亳州市","怀化市","荆州市","平顶山市","开封市","玉林市","咸阳市","宜昌市","株洲市","乌鲁木齐市","滨州市","渭南市","临汾市","榆林市","银川市","衡水市","毕节市","枣庄市","吉安市","张家口市","柳州市","许昌市","泸州市","呼和浩特市","达州市","德阳市","赤峰市","珠海市","孝感市","益阳市","娄底市","乐山市","恩施土家族苗族自治州","焦作市","湘潭市","海口市","红河哈尼族彝族自治州","黔南布依族苗族自治州","河源市","汉中市","日照市","大理白族自治州","濮阳市","黔东南苗族侗族自治州","秦皇岛市","晋中市","宝鸡市","吉林市","包头市","蚌埠市","东营市","宣城市","韶关市","衢州市","十堰市","承德市","丽水市","眉山市","鞍山市","昭通市","凉山彝族自治州","长治市","抚州市","鄂尔多斯市","吕梁市","百色市","齐齐哈尔市","贵港市","潮州市","黔西南布依族苗族自治州","广安市","淮南市","河池市","大同市","铜仁市","阳江市","咸宁市","营口市","绥化市","马鞍山市","安康市","荆门市","忻州市","广元市","内江市","遂宁市","西宁市","大庆市","汕尾市","文山壮族苗族自治州","锦州市","延安市","巴中市","呼伦贝尔市","楚雄彝族自治州","黄石市","玉溪市","六盘水市","通辽市","钦州市","云浮市","梧州市","漯河市","晋城市","庆阳市","安顺市","丹东市","自贡市","朝阳市","葫芦岛市","天水市","三门峡市","湘西土家族苗族自治州","北海市","陇南市","普洱市","延边朝鲜族自治州","保山市","定西市","随州市","喀什地区","黄山市","佳木斯市","巴彦淖尔市","牡丹江市","舟山市","资阳市","商洛市","松原市","锡林郭勒盟","伊犁哈萨克自治州","萍乡市","铁岭市","乌兰察布市","丽江市","景德镇市","张家界市","抚顺市","通化市","淮北市","来宾市","临沧市","阿克苏地区","贺州市","盘锦市","昌吉回族自治州","池州市","雅安市","三亚市","平凉市","四平市","酒泉市","西双版纳傣族自治州","鹤壁市","辽阳市","白城市","吴忠市","崇左市","阜新市","朔州市","白银市","拉萨市","巴音郭楞蒙古自治州","张掖市","铜陵市","武威市","临夏回族自治州","德宏傣族景颇族自治州","新余市","甘孜藏族自治州","兴安盟","本溪市","鄂州市","黑河市","阿坝藏族羌族自治州","阳泉市","防城港市","鸡西市","仙桃市","鹰潭市","固原市","白山市","中卫市","双鸭山市","攀枝花市","石嘴山市","和田地区","海东市","塔城地区","日喀则市","济源市","伊春市","天门市","辽源市","潜江市","那曲市","铜川市","海西蒙古族藏族自治州","鹤岗市","昌都市","阿拉善盟","乌海市","儋州市","哈密市","克拉玛依市","七台河市","金昌市","甘南藏族自治州","琼海市","迪庆藏族自治州","石河子市","阿勒泰地区","文昌市","玉树藏族自治州","嘉峪关市","万宁市","怒江傈僳族自治州","林芝市","海南藏族自治州","吐鲁番市","澄迈县","陵水黎族自治县","博尔塔拉蒙古自治州","山南市","阿里地区","大兴安岭地区","海北藏族自治州","东方市","乐东黎族自治县","克孜勒苏柯尔克孜自治州","果洛藏族自治州","临高县","阿拉尔市","黄南藏族自治州","神农架林区","屯昌县","定安县","昌江黎族自治县","五家渠市","保亭黎族苗族自治县","琼中黎族苗族自治县","五指山市","白沙黎族自治县","北屯市","图木舒克市","可克达拉市","双河市","铁门关市","毕节地区","昆玉市","铜仁地区","海东地区","三沙市","吐鲁番地区","哈密地区","日喀则地区","林芝地区","昌都地区","山南地区","那曲地区"]
|
||||
citys = citys.reverse()
|
||||
for(def city : citys){
|
||||
findPois(city)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def findPois(def city){
|
||||
def findPois(city){
|
||||
def q = new BasicDBObject()
|
||||
q.put("city", city)
|
||||
q.put("run_status", new BasicDBObject('$exists', false))
|
||||
q.put("run_status", new BasicDBObject('$ne', 1))
|
||||
|
||||
def keys = new BasicDBObject()
|
||||
keys.put("_id", 1)
|
||||
@@ -67,12 +68,22 @@ class PoiLocation {
|
||||
index++
|
||||
def datas = checkData(index, rets)
|
||||
// updateToEs(datas)
|
||||
updateToEs2(datas)
|
||||
updateToMG(datas)
|
||||
// updateToEs2(datas)
|
||||
// updateToMG(datas)
|
||||
rets = []
|
||||
print "."
|
||||
}
|
||||
}
|
||||
|
||||
if(rets.size()>0){
|
||||
index++
|
||||
def datas = checkData(index, rets)
|
||||
// updateToEs(datas)
|
||||
// updateToEs2(datas)
|
||||
// updateToMG(datas)
|
||||
rets = []
|
||||
print "."
|
||||
}
|
||||
return rets;
|
||||
}
|
||||
|
||||
@@ -92,6 +103,10 @@ class PoiLocation {
|
||||
if(map.update_status && map.update_status!=100){
|
||||
println "[ ${index} ]"+d.city +" "+totalCount.get() +"/"+rets.size()+" "+map.id+" "+d.district+" Ô£º"+d.township+" Уº"+map.township
|
||||
}
|
||||
if (map.update_status && map.update_status !=100) {
|
||||
updateMapPoi(map.id, map.township)
|
||||
}
|
||||
updateToMG(map)
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace()
|
||||
println d.city +" "+d.name
|
||||
@@ -115,7 +130,9 @@ class PoiLocation {
|
||||
def regionFlag = null
|
||||
if(d.district){
|
||||
for(def rs : regions){
|
||||
regionFlag = InsidePolygon.isInArea(d.location.lon, d.location.lat, InsidePolygon.createPoint4(rs.shape.coordinates))
|
||||
if(rs.shape && rs.shape.coordinates){
|
||||
regionFlag = InsidePolygon.isInArea(d.location.lon, d.location.lat, InsidePolygon.createPoint4(rs.shape.coordinates))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,9 +246,14 @@ class PoiLocation {
|
||||
}
|
||||
"""
|
||||
HttpRequest request = new HttpRequest()
|
||||
String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8")
|
||||
def response = JSONObject.fromObject(res)
|
||||
println(response)
|
||||
try{
|
||||
String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8")
|
||||
def response = JSONObject.fromObject(res)
|
||||
println(response)
|
||||
}catch(Exception e){
|
||||
println "error : "+e.getMessage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -293,10 +315,10 @@ class PoiLocation {
|
||||
}
|
||||
|
||||
|
||||
def updateToMG(rows){
|
||||
def rets = []
|
||||
for(def i=0;i<rows.size();i++){
|
||||
def m = rows[i]
|
||||
def updateToMG(m){
|
||||
// def rets = []
|
||||
// for(def i=0;i<rows.size();i++){
|
||||
// def m = rows[i]
|
||||
def udata = new BasicDBObject()
|
||||
m.each{k,v->
|
||||
if(k!="id"){
|
||||
@@ -311,7 +333,7 @@ class PoiLocation {
|
||||
println m.toString()+" ÎÞ·¨ÐÞ¸Ä-ÎÞÖµ"
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class TownMiddleProcess {
|
||||
//修改乡镇街道别名
|
||||
// updateTownAlias()
|
||||
//中间表同步到100
|
||||
// synchTown()
|
||||
synchTown()
|
||||
//添加地级市标志
|
||||
// addCityFlag()
|
||||
// addPinyin()
|
||||
|
||||
+80
-4
@@ -3,9 +3,11 @@ package com.fangjia.script.gj.data_handle
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.looplineinfo.InsidePolygon
|
||||
import com.fangjia.script.util.CosineSimilarAlgorithm
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
@@ -27,7 +29,9 @@ class TownshipStrandUpdate {
|
||||
|
||||
static main(args) {
|
||||
def task = new TownshipStrandUpdate()
|
||||
task.process()
|
||||
// task.process()
|
||||
task.updateTown()
|
||||
// task.stat()
|
||||
|
||||
}
|
||||
|
||||
@@ -42,13 +46,14 @@ class TownshipStrandUpdate {
|
||||
def citys = CommonDatautils.findAllCity()
|
||||
citys = citys.reverse()
|
||||
for(def city : citys){
|
||||
if(["中山"].contains(city)){
|
||||
//
|
||||
if(["中山","东莞"].contains(city)){
|
||||
continue
|
||||
}
|
||||
def fileName = "D:\\数据\\数据建设\\乡镇街道\\小区\\小区乡镇街道格式化-${city}.xlsx"
|
||||
def fileName = "D:\\数据\\数据建设\\乡镇街道\\商铺\\商铺乡镇街道格式化-${city}.xlsx"
|
||||
File file=new File(fileName);
|
||||
if(!file.exists()){
|
||||
def dists = CommonDatautils.findAllDistrictsFromMg(city, "district", ["city","region","name","address","cat","estate_type2","status","township","lng","lat"])
|
||||
def dists = CommonDatautils.findAllDistrictsFromMg(city, "shop", ["city","region","name","address","cat","estate_type2","status","township","lng","lat"])
|
||||
dists = checkData(dists)
|
||||
def datas = createDatas(dists)
|
||||
ExcelUtils.write(fileName, datas, "${city}")
|
||||
@@ -56,6 +61,77 @@ class TownshipStrandUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
// 相同且为统计局乡镇
|
||||
// 更正
|
||||
// 不同且不为统计局乡镇
|
||||
// 区域不同
|
||||
// 地图无乡镇街道
|
||||
// 城市不同
|
||||
|
||||
def stat(){
|
||||
def citys = CommonDatautils.findAllCity()
|
||||
citys = citys.reverse()
|
||||
def rets = []
|
||||
rets << ["城市", "小区量", "更正量","相同且为统计局乡镇","不同且不为统计局乡镇","区域不同","地图无乡镇街道","城市不同","无值"]
|
||||
for(def city : citys){
|
||||
def fileName = "D:\\数据\\数据建设\\乡镇街道\\商铺\\商铺乡镇街道格式化-${city}.xlsx"
|
||||
File file=new File(fileName);
|
||||
def map = [:]
|
||||
def datas = null
|
||||
if(file.exists()){
|
||||
datas = ExcelUtils.read(fileName,0, 1)
|
||||
for(def d : datas){
|
||||
def key = "空值"
|
||||
if(d['S']){
|
||||
key = d['S']
|
||||
}
|
||||
def count = map.get(key)
|
||||
if(!count){
|
||||
count = 0
|
||||
}
|
||||
map.put(key, count+1)
|
||||
}
|
||||
}
|
||||
|
||||
println city
|
||||
map.each {k,v->
|
||||
println k+" "+v
|
||||
}
|
||||
println "--------------------------------------------------------------------------------------------"
|
||||
if(map){
|
||||
rets << [city, datas.size(), map.get("更正"),map.get("相同且为统计局乡镇"),map.get("不同且不为统计局乡镇"),map.get("区域不同"),map.get("地图无乡镇街道"),map.get("城市不同"),map.get("空值")]
|
||||
}
|
||||
|
||||
}
|
||||
ExcelUtils.write("D:\\数据\\数据建设\\乡镇街道\\乡镇街道更新结果统计.xlsx", rets, "商铺")
|
||||
}
|
||||
|
||||
def updateTown(){
|
||||
def citys = CommonDatautils.findAllCity()
|
||||
citys = citys.reverse()
|
||||
for(def city : citys){
|
||||
def fileName = "D:\\数据\\数据建设\\乡镇街道\\商铺\\商铺乡镇街道格式化-${city}.xlsx"
|
||||
File file=new File(fileName);
|
||||
if(file.exists()){
|
||||
println fileName
|
||||
ExcelUtils.multiThreadingModify(fileName,{d->
|
||||
if(d['S']!='相同且为统计局乡镇' && d['S']){
|
||||
def q = new BasicDBObject()
|
||||
q.put("city", d['A'])
|
||||
q.put("region", d['B'])
|
||||
q.put("name", d['C'])
|
||||
q.put("status", 0)
|
||||
q.put("cat","shop")
|
||||
|
||||
def udata = new BasicDBObject()
|
||||
udata.put("township", d['R'])
|
||||
DbUtils.seaweed.update(q, new BasicDBObject('$set', udata))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def checkData(def dists){
|
||||
def totalCount = new AtomicLong()
|
||||
def rets = new CopyOnWriteArrayList()
|
||||
|
||||
+5
-7
@@ -36,18 +36,16 @@ class SeaweedDataMatchProcess {
|
||||
}
|
||||
}
|
||||
|
||||
if(!rMap && name){
|
||||
rMap = OpenApiUtils.matchDistrict(city, name, region, false)
|
||||
}
|
||||
|
||||
|
||||
if(!rMap && address){
|
||||
if(!rMap && address && name){
|
||||
def flag = address.matches('^[\u4e00-\u9fa5]+?(路|大道|街).+[弄号]$')
|
||||
if(flag){
|
||||
rMap = OpenApiUtils.matchDistrict(city, address, region, true)
|
||||
rMap = OpenApiUtils.matchDistrict(city, address, region, true, name)
|
||||
}
|
||||
}
|
||||
|
||||
if(!rMap && name){
|
||||
rMap = OpenApiUtils.matchDistrict(city, name, region, false, null)
|
||||
}
|
||||
// if(rMap && rMap.id && region.contains(rMap.region)) {
|
||||
// def obj = CommonDatautils.findDistrictById(rMap.id.toString());
|
||||
// if (obj) {
|
||||
|
||||
+20
-16
@@ -5,28 +5,19 @@ import com.fangjia.core.util.DataUtil
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.gj.ccb.CcbCodeUtils
|
||||
import com.fangjia.script.gj.ccb.FileUtils
|
||||
import com.fangjia.script.gj.district.SeaweedDataMatchProcess
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.fangjia.script.util.OpenApiClient
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.rabbitmq.client.impl.AMQImpl
|
||||
import groovy.sql.Sql
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import java.util.regex.Pattern
|
||||
|
||||
/**
|
||||
* 建行模型估值项目
|
||||
* 成交数据同步
|
||||
@@ -59,7 +50,7 @@ class FjwBigdataDealBatch extends BaseBatch{
|
||||
@Override
|
||||
public void process(Object args) {
|
||||
|
||||
def citys = ["ÎÚ³ľÆë"] //CcbCommonUtils.getRunningCitys(args)
|
||||
def citys = CcbCommonUtils.getRunningCitys(args)
|
||||
|
||||
// println "curDate:"+curDate
|
||||
// def allCitys = CommonDatautils.findAllCity()
|
||||
@@ -130,7 +121,7 @@ class FjwBigdataDealBatch extends BaseBatch{
|
||||
|
||||
def ccbPriceMap = null
|
||||
if(city == "上海"){
|
||||
ccbPriceMap = getCommunityPrices("ÉϺ£")
|
||||
ccbPriceMap = [:]//getCommunityPrices("ÉϺ£")
|
||||
}
|
||||
|
||||
for(def i=0;i<rets.size();i++){
|
||||
@@ -169,13 +160,25 @@ class FjwBigdataDealBatch extends BaseBatch{
|
||||
})
|
||||
}
|
||||
println "查询完成......."
|
||||
latch.await(5, TimeUnit.MINUTES);
|
||||
|
||||
latch.await();
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
|
||||
def getCommunityPrices(def city){
|
||||
def sql = "select commid, avg_price from community_base_price where year_month=${endDate} and cityname='${city}'";
|
||||
def map = [:]
|
||||
try{
|
||||
sqlInstance.eachRow(sql,{
|
||||
map.put(it.commid, it.avg_price)
|
||||
});
|
||||
}catch(Exception e){
|
||||
//getPpeGTE15Datas(city)
|
||||
}
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
def findThirdPartyPrice(def city) {
|
||||
def q = new BasicDBObject()
|
||||
@@ -518,7 +521,7 @@ class FjwBigdataDealBatch extends BaseBatch{
|
||||
// def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date())
|
||||
|
||||
def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20200101", "yyyyMMdd"))
|
||||
def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240501", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date())
|
||||
def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240601", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date())
|
||||
|
||||
|
||||
for(def i=0;i<dists.size();i++){
|
||||
@@ -578,7 +581,8 @@ class FjwBigdataDealBatch extends BaseBatch{
|
||||
}
|
||||
|
||||
def getYouDaData(statMap){
|
||||
def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))
|
||||
// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))
|
||||
def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20200101", "yyyyMMdd"))
|
||||
def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))
|
||||
def q = new BasicDBObject()
|
||||
q.put("contractTime", new BasicDBObject('$gte', startDate).append('$lte', endDate));
|
||||
|
||||
+25
-17
@@ -33,11 +33,11 @@ class AddPriceTest {
|
||||
task.run();
|
||||
}
|
||||
def run(){
|
||||
def filePath = "D:\\数据\\建行\\房产估值\\神经网络计算.xlsx"
|
||||
addGXDPrice(filePath)
|
||||
def filePath = "D:\\数据\\建行\\分期小区对比结果.xlsx"
|
||||
// addGXDPrice(filePath)
|
||||
// addCcbPrice(filePath)
|
||||
// addThirdPrice(filePath)
|
||||
// addFjwPrice(filePath)
|
||||
addFjwPrice(filePath)
|
||||
// exportPkPrice()
|
||||
// addRegion()
|
||||
// addTradePrice(filePath)
|
||||
@@ -205,7 +205,7 @@ class AddPriceTest {
|
||||
def addThirdPrice(filepath){
|
||||
ExcelUtils.multiThreadingModify(filepath, { d ->
|
||||
if (!d['X']) {
|
||||
def dist = CommonDatautils.findDistrictById(d['Y'])
|
||||
def dist = CommonDatautils.findDistrictById(d['A'])
|
||||
if(dist){
|
||||
def thirdPrice = findThirdPartyPrice(dist.city, dist.region, dist.name)
|
||||
d['X'] = thirdPrice
|
||||
@@ -220,8 +220,8 @@ class AddPriceTest {
|
||||
q.put("city", city)
|
||||
q.put("region", region)
|
||||
q.put("name", name)
|
||||
// q.put("s_date", new BasicDBObject('$gte', 202311).append('$lte',202404))
|
||||
q.put("s_date", 202404)
|
||||
q.put("s_date", new BasicDBObject('$gte', 202403))
|
||||
// q.put("s_date", 202404)
|
||||
def dbcursor = AVERAGE_STATISTICS.find(q).sort(new BasicDBObject("s_date", -1))
|
||||
def price = null
|
||||
for(def db : dbcursor){
|
||||
@@ -270,20 +270,28 @@ class AddPriceTest {
|
||||
|
||||
def addFjwPrice(path){
|
||||
ExcelUtils.multiThreadingModify(path,{d->
|
||||
if(!d['L']){
|
||||
if(d['B'] instanceof String){
|
||||
def dist = CommonDatautils.findDistrictById(d['B'])
|
||||
// if(!d['L']){
|
||||
// if(d['J'] instanceof String){
|
||||
def dist = CommonDatautils.findDistrictById(d['J'])
|
||||
if(dist){
|
||||
d['A'] = dist.city
|
||||
d['B'] = dist.region
|
||||
d['C'] = dist.name
|
||||
d['D'] = dist.status
|
||||
d['E'] = dist.name_cat
|
||||
d['F'] = dist.estate_type2
|
||||
d['G'] = DateUtils.formatDateByPattern(dist.m_date,'yyyy-MM-dd')
|
||||
d['H'] = dist.master_district_name
|
||||
// d['N'] = dist.region
|
||||
def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name)
|
||||
if(dbo){
|
||||
// d['W'] = dbo.avg_price
|
||||
// d['X'] = dbo.cal_type
|
||||
d['L'] = dbo.avg_price_2b
|
||||
}
|
||||
// def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name)
|
||||
// if(dbo){
|
||||
// d['D'] = dbo.avg_price
|
||||
//// d['X'] = dbo.cal_type
|
||||
// d['E'] = dbo.avg_price_2b
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+83
-2
@@ -27,13 +27,94 @@ class QiliangTest {
|
||||
// task.run()
|
||||
|
||||
def data = [
|
||||
'address': '福建省闽侯县上街镇乌龙江南大道30号福州清华紫光科技园-海峡科技研发区1-3#研发楼12层1201研发',
|
||||
'type': '1' //1:对公 0:对私
|
||||
'address': '宁德市福安市中兴西路16号',
|
||||
'type': '2' //1:对公 0:对私
|
||||
]
|
||||
def s = task.getProxyResult(data);
|
||||
print(s);
|
||||
}
|
||||
|
||||
def run(){
|
||||
ExcelUtils.modify("C:\\Users\\gaojuan\\Desktop\\对公地址(问题案例)跑一下结果.xlsx", { row ->
|
||||
if(row['B']){
|
||||
def parmas = [
|
||||
'address': row['B'],
|
||||
'type': '1' //1:对公 0:对私
|
||||
]
|
||||
def str = getProxyResult(parmas);
|
||||
println str
|
||||
JSONObject result = JSONObject.fromObject(str)
|
||||
if(result && result.code==20000){
|
||||
def data = result.data
|
||||
if(data){
|
||||
if(data.province && data.province!='null'){
|
||||
row['C'] = data.province
|
||||
}
|
||||
if(data.provinceCode && data.provinceCode!='null'){
|
||||
row['D'] = data.provinceCode
|
||||
}
|
||||
if(data.city && data.city!='null'){
|
||||
row['E'] = data.city
|
||||
}
|
||||
if(data.cityCode && data.cityCode!='null'){
|
||||
row['F'] = data.cityCode
|
||||
}
|
||||
|
||||
if(data.district && data.district!='null'){
|
||||
row['G'] = data.district
|
||||
}
|
||||
if(data.districtCode && data.districtCode!='null'){
|
||||
row['H'] = data.districtCode
|
||||
}
|
||||
|
||||
if(data.town && data.town!='null'){
|
||||
row['I'] = data.town
|
||||
}
|
||||
if(data.townCode && data.townCode!='null'){
|
||||
row['J'] = data.townCode
|
||||
}
|
||||
|
||||
if(data.village && data.village!='null'){
|
||||
row['K'] = data.village
|
||||
}
|
||||
if(data.villageCode && data.villageCode!='null'){
|
||||
row['L'] = data.villageCode
|
||||
}
|
||||
|
||||
if(data.areaCode && data.areaCode!='null'){
|
||||
row['M'] = data.areaCode
|
||||
}
|
||||
|
||||
|
||||
if(data.farmer == "0"){
|
||||
row['N'] = "非农"
|
||||
}else{
|
||||
row['N'] = "农"
|
||||
}
|
||||
if(data.isGovt == "0"){
|
||||
row['O'] = "否"
|
||||
}else{
|
||||
row['O'] = "是"
|
||||
}
|
||||
|
||||
def list = data.indusParkList
|
||||
if(list && list!="null"){
|
||||
def s = ""
|
||||
for(def r : list){
|
||||
s = s + r.indusParkName +"-"+r.indusParkLevel+"\n"
|
||||
}
|
||||
row['P'] = s
|
||||
}
|
||||
if(data.govtAddr && data.govtAddr!='null'){
|
||||
row['Q'] = data.govtAddr?data.govtAddr:''
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -186,6 +186,26 @@ public class DbUtils{
|
||||
return query
|
||||
}
|
||||
|
||||
public static BasicDBObject buildSeaweedQuery2(def city = null, def region = null, def name = null, def cat = "district", def status = 0){
|
||||
BasicDBObject query = new BasicDBObject()
|
||||
if(city){
|
||||
query.append("city", city)
|
||||
}
|
||||
if(region){
|
||||
query.append("region", region)
|
||||
}
|
||||
if(name){
|
||||
query.append("name", name)
|
||||
}
|
||||
if(cat != null){
|
||||
query.append("cat", cat)
|
||||
}
|
||||
if(status != null){
|
||||
query.append("status", status)
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
/**
|
||||
* 把小区修改成删除状态
|
||||
* @param id
|
||||
|
||||
@@ -156,6 +156,22 @@ public class ProvinceData {
|
||||
return PROVINCE_MAP.get(province);
|
||||
}
|
||||
|
||||
|
||||
public static String getSimpleProvince(String province){
|
||||
def prov = null
|
||||
def newDatas = data + GOVERNMENT_CITY_LIST
|
||||
for(def key : newDatas.keySet()){
|
||||
def list = newDatas.get(key)
|
||||
list << key
|
||||
if(list.contains(province)){
|
||||
prov = key
|
||||
break;
|
||||
}
|
||||
}
|
||||
return prov;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取省份下的所有城市
|
||||
* @param province
|
||||
|
||||
@@ -234,5 +234,10 @@
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka_2.13</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
+7
-1
@@ -4,6 +4,7 @@ import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.open.dao.OpenUriLogDao;
|
||||
import com.fangjia.dal.mongo.tool.model.OpenUriLog;
|
||||
import com.fangjia.service.util.kafka.KafkaProducerUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -13,9 +14,12 @@ import java.util.List;
|
||||
public class OpenUriLogServiceImpl implements OpenUriLogService {
|
||||
|
||||
private OpenUriLogDao openUriLogDao;
|
||||
private KafkaProducerUtils kafkaProducerUtils;
|
||||
|
||||
public void save(OpenUriLog openUriLog) {
|
||||
this.openUriLogDao.save(openUriLog);
|
||||
// 改造为向Kafka中发送消息
|
||||
kafkaProducerUtils.sendLog(openUriLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,5 +99,7 @@ public class OpenUriLogServiceImpl implements OpenUriLogService {
|
||||
this.openUriLogDao = openUriLogDao;
|
||||
}
|
||||
|
||||
|
||||
public void setKafkaProducerUtils(KafkaProducerUtils kafkaProducerUtils) {
|
||||
this.kafkaProducerUtils = kafkaProducerUtils;
|
||||
}
|
||||
}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.fangjia.service.util.kafka;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fangjia.dal.mongo.tool.model.OpenUriLog;
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
@Service
|
||||
public class KafkaProducerUtils implements DisposableBean {
|
||||
public final KafkaProducer<String, String> producer;
|
||||
|
||||
public KafkaProducerUtils() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.0.100:30092");
|
||||
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
|
||||
this.producer = new KafkaProducer<String, String>(properties);
|
||||
}
|
||||
|
||||
public void sendLog(OpenUriLog openUriLog) {
|
||||
try {
|
||||
String msg = JSONObject.toJSONString(openUriLog);
|
||||
ProducerRecord<String, String> record = new ProducerRecord<String, String>("log-data-topic", msg);
|
||||
this.producer.send(record);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
producer.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user