This commit is contained in:
mjt
2024-02-28 14:32:23 +08:00
66 changed files with 2548 additions and 255 deletions
@@ -269,7 +269,9 @@ public class ApiUserController {
public Object updateAction(ApiUserModel model) {
Long userId = model.getUserId();
Map<String, Object> dataApiUser = new HashMap<String, Object>();
// Map<String, Object> user = new HashMap<String, Object>();
dataApiUser.put("email", model.getEmail());
// user.put("password", DigestUtils.md5Hex(model.getPassword()));
dataApiUser.put("siteName", model.getSiteName());
dataApiUser.put("ip", model.getIp());
dataApiUser.put("company", model.getCompany());
@@ -279,6 +281,11 @@ public class ApiUserController {
dataApiUser.put("manager", model.getManager());
dataApiUser.put("isMonitor", model.getIsMonitor());
this.apiUserService.update(dataApiUser, userId);
// 更改用户密码
// this.userService.updateById(user,userId);
// 刷新缓存
// this.apiUserService.clearApiUserAuthorityCache(userId);
//ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE
modifyUserCfg(userId, ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE, model.getEvaluateRate());
@@ -290,6 +297,30 @@ public class ApiUserController {
return model;
}
public Object doEditPwdAction(ApiUserModel model) {
Long userId = model.getUserId();
Map<String, Object> user = new HashMap<String, Object>();
user.put("password", DigestUtils.md5Hex(model.getPassword()));
//
// // 更改用户密码
this.userService.updateById(user,userId);
// 刷新缓存
this.apiUserService.clearApiUserAuthorityCache(userId);
model.setViewType("redirect");
model.setViewParam("location", "/apiUser/edit?userId="+userId);
return model;
}
public Object editPwdAction(ApiUserModel model) {
Long userId = model.getUserId();
User user = this.userService.findById(userId);
ApiUserBo bo = new ApiUserBo();
bo.setUserName(user.getUserName());
bo.setDisplayName(user.getDisplayName());
model.setApiUserBo(bo);
return model;
}
void modifyUserCfg(Long userId, ApiUserCfg.ApiUserCfgKey cfgKey, Object val) {
if (userId != null && cfgKey != null) {
ApiUserCfg apiUserCfg = this.apiUserCfgService.findByUserId(userId, cfgKey);
@@ -43,10 +43,20 @@
<input id="userId" name="userId" value="${userId!}" type="hidden"/>
<td>${apiUserBo.userName!}<#if (apiUserBo.displayName??)>(${apiUserBo.displayName!})</#if></td>
</tr>
<#-- <tr>-->
<#-- <td>密码</td>-->
<#-- <td><input id="resetPwd" type="button" value="重置密码"/></td>-->
<#-- </tr>-->
<#-- <tr>-->
<#-- <td><b>密码</b></td>-->
<#-- <td><input name="password" value="${apiUserBo.password!}" /></td>-->
<#-- </tr>-->
<tr>
<td>密码</td>
<td><input id="resetPwd" type="button" value="重置密码"/></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../apiUser/editPwd?userId=${apiUserBo.userId!}">修改密码</a>
</td>
</tr>
<tr>
<td>账户类型</td>
<td>
@@ -151,15 +161,15 @@
return re.test(strIP)
}
$("#resetPwd").click(function () {
if (confirm('确认重置密码为【123456】?')) {
$.get('resetPwd',
"userId=" + $("#userId").val(),
function (data) {
alert(status);
})
}
})
// $("#resetPwd").click(function () {
// if (confirm('确认重置密码为【123456】?')) {
// $.get('resetPwd',
// "userId=" + $("#userId").val(),
// function (data) {
// alert(status);
// })
// }
// })
</script>
</body>
</html>
@@ -0,0 +1,54 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
<#compress>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>api用户密码修改</title>
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}"/>
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<#include "/common_js.ftl" />
<script type="text/javascript">
</script>
</head>
<body>
<#include "/layout/header.ftl" />
<div class="main-content">
<div class="list">
<table width="50%">
<form id="submitForm" action="doEditPwd" method="post" >
<tr>
<td>用户名</td>
<input id="userId" name="userId" value="${userId!}" type="hidden"/>
<td>${apiUserBo.userName!}<#if (apiUserBo.displayName??)>(${apiUserBo.displayName!})</#if></td>
</tr>
<tr>
<td><b>新密码</b></td>
<td><input name="password" value="${apiUserBo.password!}" /></td>
</tr>
</form>
<tr>
<td></td>
<td><input onclick="submitForm();" type="reset" value="修改"/></td>
</tr>
</table>
</div>
</div>
<script type="text/javascript">
function submitForm() {
$("#submitForm").attr("action", "doEditPwd");
$("#submitForm").submit();
}
function isIP(strIP) {
if (!strIP)
return false;
var re = /^(\d+)(\.(\d+)){0,3}$/g //匹配IP地址的正则表达式
return re.test(strIP)
}
</script>
</body>
</html>
</#compress>
@@ -0,0 +1,8 @@
package com.fangjia.dal.mongo.dao;
import com.fangjia.dal.mongo.model.AdministrativeDivision;
import com.fangjia.dal.MongoDao;
public interface AdministrativeDivisionDao extends MongoDao<AdministrativeDivision> {
AdministrativeDivision findcityByCode(String code);
}
@@ -0,0 +1,23 @@
package com.fangjia.dal.mongo.dao;
import com.fangjia.dal.mongo.model.AdministrativeDivision;
import com.fangjia.dal.MongoDaoImpl;
import com.fangjia.dal.QueryParam;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class AdministrativeDivisionDaoImpl extends MongoDaoImpl<AdministrativeDivision> implements AdministrativeDivisionDao {
@Override
public AdministrativeDivision findcityByCode(String code) {
if (StringUtils.isBlank(code)) {
return new AdministrativeDivision();
}
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("mcaCityCode", QueryParam.EQUAL_OPERATOR, code));
params.add(new QueryParam("level", QueryParam.EQUAL_OPERATOR, "³ÇÊÐ"));
return (AdministrativeDivision) findFirstByParams(params);
}
}
@@ -0,0 +1,148 @@
package com.fangjia.dal.mongo.model;
import com.fangjia.dal.DatastoreCategory;
import com.fangjia.dal.MongoEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "fangjia.administrative_division")
public class AdministrativeDivision implements MongoEntity {
private static final long serialVersionUID = -8379446820760559477L;
private String id;
private String province;
private String city;
private String district;
private String mcaProvinceCode;
private String mcaDistrictCode;
private String mcaCityCode;
private String level;
private String cityShort;
private String distShort;
private String provShort;
private String code;
private String administer;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "_id")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
@Column(name = "mca_province_code")
public String getMcaProvinceCode() {
return mcaProvinceCode;
}
public void setMcaProvinceCode(String mcaProvinceCode) {
this.mcaProvinceCode = mcaProvinceCode;
}
@Column(name = "mca_district_code")
public String getMcaDistrictCode() {
return mcaDistrictCode;
}
public void setMcaDistrictCode(String mcaDistrictCode) {
this.mcaDistrictCode = mcaDistrictCode;
}
@Column(name = "mca_city_code")
public String getMcaCityCode() {
return mcaCityCode;
}
public void setMcaCityCode(String mcaCityCode) {
this.mcaCityCode = mcaCityCode;
}
@Column(name = "level")
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
@Column(name = "city_short")
public String getCityShort() {
return cityShort;
}
public void setCityShort(String cityShort) {
this.cityShort = cityShort;
}
@Column(name = "dist_short")
public String getDistShort() {
return distShort;
}
public void setDistShort(String distShort) {
this.distShort = distShort;
}
@Column(name = "prov_short")
public String getProvShort() {
return provShort;
}
public void setProvShort(String provShort) {
this.provShort = provShort;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getAdminister() {
return administer;
}
public void setAdminister(String administer) {
this.administer = administer;
}
}
@@ -206,7 +206,7 @@ public class AddrSvcController {
//新匹配接口
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
BasicModel basicModel = new BasicModel(200, "ok");
if (json != null && json.size()>0) {
if (json != null && json.size() > 0) {
basicModel.setResult(CommonDtoUtils.transformV(MatchedBuildingDto.class, json));
}
mav.setModel(basicModel);
@@ -284,16 +284,16 @@ public class AddrSvcController {
//新匹配接口
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
BasicModel basicModel = new BasicModel(200, "ok");
if (json != null && json.size()>0) {
if (json != null && json.size() > 0) {
MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json);
District district = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(),"district");
District district = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), "district");
if (null != district) {
DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName()));
if(null != statBo){
if(statBo.getDistrictStat()!=null){
if (null != statBo) {
if (statBo.getDistrictStat() != null) {
dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice());
}else if(statBo.getVillaDistrictStat()!=null){
} else if (statBo.getVillaDistrictStat() != null) {
dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice());
}
@@ -310,6 +310,102 @@ public class AddrSvcController {
return mav;
}
/**
* 五级地址标准化
*
* @param model
* @return
*/
public Object fiveLevelStructureAction(AddesssMatchModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress())) {
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("refCity", StringUtils.isNotBlank(model.getRefCity()) ? model.getRefCity() : null);
params.put("address", model.getAddress());
// 默认不输出省市区的代码
params.put("showCode", StringUtils.isNotBlank(model.getShowCode()) ? model.getShowCode() : "0");
params.put("complete", "true");
params.put("addressAssessment", "true");
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v3/structure", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v3/structure", 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;
}
/**
* 涉农识别-新规则
*
* @param model
* @return
*/
public Object villageIdentifyAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress())) {
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("address", model.getAddress());
params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null);
params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null);
params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null);
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/villageIdentify", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", 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;
}
@@ -1989,6 +1989,7 @@ public class AddressController {
return mav;
}
/**
* 详细地址标准化接口
*
@@ -1,18 +1,16 @@
package com.fangjia.open.controllers;
import com.fangjia.core.util.*;
import com.fangjia.dal.mongo.model.AdministrativeDivision;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.ApiUserCfg;
import com.fangjia.dal.mongo.model.DistrictFacilitys;
import com.fangjia.dal.mongo.model.Evaluation;
import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
import com.fangjia.dal.mongo.model.bkoff.Loudong;
import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.open.HttpCode;
import com.fangjia.open.OpenHttpCodeEnum;
import com.fangjia.open.dto.HouseValueInformationDto;
import com.fangjia.open.dto.UniversalDto;
import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto;
@@ -35,7 +33,6 @@ import com.fangjia.service.mongo.bkoff.HouseLoudongService;
import com.fangjia.service.mongo.bkoff.LoudongService;
import com.fangjia.service.mongo.fangjia.*;
import com.fangjia.service.open.*;
import com.fangjia.service.tool.OpenLogService;
import com.fangjia.service.web.AddressService;
import net.sf.json.JSONObject;
import org.apache.commons.lang.ArrayUtils;
@@ -84,6 +81,7 @@ public class ComprehensiveQueryController {
static final int BAI_DU_GEO = 1;// 百度系坐标
static final int GAO_DE_GEO = 2;// 高德系坐标
private AdministrativeDivisionService administrativeDivisionService;
private EvaluateRatioService evaluateRatioService;
@@ -218,10 +216,21 @@ public class ComprehensiveQueryController {
return mav;
}
String cityStr = model.getCity();
if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+")) {
AdministrativeDivision administrativeDivision = administrativeDivisionService.findcityByCode(cityStr);
String city = administrativeDivision.getCityShort();
if (StringUtils.isBlank(city)) {
mav.setModel(BasicModel.buildBadRequestModel("城市代码错误"));
return mav;
}
model.setCity(city);
}
HttpRequest httpRequest = new HttpRequest();
JSONObject json = null;
Map<String, String> communityAvgPriceParams = new HashMap<String, String>();
// communityAvgPriceParams.put("city", model.getCity());
communityAvgPriceParams.put("city", model.getCity());
communityAvgPriceParams.put("address", model.getAddress());
communityAvgPriceParams.put("category", model.getCategory());
communityAvgPriceParams.put("useMap", String.valueOf(model.isUseMap()));
@@ -232,7 +241,7 @@ public class ComprehensiveQueryController {
} catch (HttpRequestException e) {
}
if(matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) {
if (matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) {
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
return mav;
}
@@ -267,6 +276,8 @@ public class ComprehensiveQueryController {
district = bieShuDistrict;
}
}
//添加城市
propertyEvaluationModel.setCity(district.getCity());
propertyEvaluationModel.setDistrict(district.getRegion());
propertyEvaluationModel.setName(district.getName());
try {
@@ -287,7 +298,7 @@ public class ComprehensiveQueryController {
// RestfulModelAndView houseCaseMav = new RestfulModelAndView();
List<CollateralSampleQueryBean> querys = null;
try {
querys = convertSampileQueryToBean(district,sampleQuery);
querys = convertSampileQueryToBean(district, sampleQuery);
} catch (Exception e) {
mav.setModel(BasicModel.buildBadRequestModel(e.getMessage()));
return mav;
@@ -299,7 +310,7 @@ public class ComprehensiveQueryController {
long start = System.currentTimeMillis();
List<Collateral> collaterals = czbankSampleService.findSample2(querys, sampleQuery.getMax());
long end = System.currentTimeMillis();
System.out.println("用时:"+(end-start));
System.out.println("用时:" + (end - start));
Collateral collateral = collaterals.get(0);
List<Sample> samples = collateral.getSample();
UniversalDto houseCaseDto = UniversalDto.newDto();
@@ -426,7 +437,7 @@ public class ComprehensiveQueryController {
return propertyModel;
}
private List<CollateralSampleQueryBean> convertSampileQueryToBean(District district,SampleQuery... queries) throws Exception {
private List<CollateralSampleQueryBean> convertSampileQueryToBean(District district, SampleQuery... queries) throws Exception {
List<CollateralSampleQueryBean> queryBeans = new ArrayList<CollateralSampleQueryBean>(queries.length);
for (SampleQuery q : queries) {
@@ -498,10 +509,10 @@ public class ComprehensiveQueryController {
throws NumberFormatException, IllegalAccessException {
// RestfulModelAndView mav = new RestfulModelAndView();
// mav.setViewType("rest");
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
if (StringUtils.isBlank(model.getName())
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
return mav;
mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域,小区名,面积(size)为必填项"));
// return mav;
}
if (model.getCity().endsWith("市")) {
model.setCity(model.getCity().replaceAll("市$", ""));
@@ -1230,8 +1241,6 @@ public class ComprehensiveQueryController {
}
public void setEvaluationService(EvaluationService evaluationService) {
this.evaluationService = evaluationService;
}
@@ -1254,7 +1263,6 @@ public class ComprehensiveQueryController {
}
public BatchEvaluateService getBatchEvaluateService() {
return batchEvaluateService;
}
@@ -1313,5 +1321,8 @@ public class ComprehensiveQueryController {
this.districtFacilitysService = districtFacilitysService;
}
public void setAdministrativeDivisionService(AdministrativeDivisionService administrativeDivisionService) {
this.administrativeDivisionService = administrativeDivisionService;
}
}
@@ -880,8 +880,13 @@ public class PropertyController {
districtInfoDto.setAddressAlias(district.getAddrAlias());
if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null
&& district.getLng2() != 0) {
districtInfoDto.setLat(district.getLat2() / 10000000000D);
districtInfoDto.setLng(district.getLng2() / 10000000000D);
districtInfoDto.setLat2(district.getLat2() / 10000000000D);
districtInfoDto.setLng2(district.getLng2() / 10000000000D);
}
if (district.getLat() != null && district.getLat() != 0 && district.getLng() != null
&& district.getLng() != 0) {
districtInfoDto.setLat(district.getLat() / 10000000000D);
districtInfoDto.setLng(district.getLng() / 10000000000D);
}
districtInfoDto.setPropertyType(district.getEstateType2());
if (HouseValidator.validateBuildingType(district.getBuildType())) {
@@ -542,7 +542,7 @@ public class UserController {
String code = usersInfoService.randomCode();
System.out.println(code);
try {
smsService.send(model.getMobile(), "【房价网】你的验证码是" + code + ",请立即验证。");
smsService.send(model.getMobile(), "【百盛评估】你的验证码是" + code + ",请立即验证。");
resultModel.setResult(Message.RESULT_SUCCESS);
CookieUtils.setCookie(mobile + "_" + type, code, "/", 60 * 60 * 24 *7, resp);
CacheUtils.putValue(CachePolicyEnum.TINY, FjtUsers.class, mobile, new Date().getTime());
@@ -1285,15 +1285,17 @@ public class WeiXinEvaluationController {
Point point = null;
if(district.getLng2()!=null){
point = new Point(district.getLng2()/10000000000.0, district.getLat2()/10000000000.0);
//boolean flag = InsidePolygon.aboutZone(point, points);
//boolean flag = InsidePolygon.isPtInPoly(point.getLon(), point.getLat(), points);
boolean flag = InsidePolygon2.checkIsInPolygon(point, points);
if(flag){
pbObj = pb;
System.out.println(district.getRegion()+" "+district.getName()+" "+pb.getName());
break;
}
}
//boolean flag = InsidePolygon.aboutZone(point, points);
//boolean flag = InsidePolygon.isPtInPoly(point.getLon(), point.getLat(), points);
boolean flag = InsidePolygon2.checkIsInPolygon(point, points);
if(flag){
pbObj = pb;
System.out.println(district.getRegion()+" "+district.getName()+" "+pb.getName());
break;
}
}
Integer yearAge = getBuildYear(district.getFinishBuildingDate());
if(pbObj!=null){
@@ -26,8 +26,14 @@ public class DistrictInfoDto {
private List<String> alias;
private List<String> addressAlias;
private String videoUrl;
//高德坐标
//维度
private Double lat;
//经度
private Double lng;
// 百度坐标
private Double lat2;
private Double lng2;
private String developer;
private String buildType;
private String estateCompany;
@@ -102,7 +108,22 @@ public class DistrictInfoDto {
private String township;
private String landProperty;
public Double getLat2() {
return lat2;
}
public void setLat2(Double lat2) {
this.lat2 = lat2;
}
public Double getLng2() {
return lng2;
}
public void setLng2(Double lng2) {
this.lng2 = lng2;
}
public String getDistrict() {
return district;
}
@@ -9,6 +9,7 @@ import org.hibernate.validator.constraints.NotBlank;
public class AddesssMatchModel extends FangjiaApiModel {
private String city;
private String refCity;
@NotBlank
private String address;
private String suggestDistrict;
@@ -24,6 +25,14 @@ public class AddesssMatchModel extends FangjiaApiModel {
private String showCode;
public String getRefCity() {
return refCity;
}
public void setRefCity(String refCity) {
this.refCity = refCity;
}
public String getAddress_1() {
return address_1;
}
@@ -42,6 +42,10 @@ public class AddressModel extends FangjiaApiModel {
//是否使用地图poi数据
private boolean useMap;
//涉农到区之后,是否显式后面的字段值
private String showFullValue;
//是否显示涉农测试用字段值
private String showTestValue;
public boolean isContainsLocation() {
return containsLocation;
}
@@ -258,4 +262,20 @@ public class AddressModel extends FangjiaApiModel {
public void setUseMap(boolean useMap) {
this.useMap = useMap;
}
public String getShowFullValue() {
return showFullValue;
}
public void setShowFullValue(String showFullValue) {
this.showFullValue = showFullValue;
}
public String getShowTestValue() {
return showTestValue;
}
public void setShowTestValue(String showTestValue) {
this.showTestValue = showTestValue;
}
}
@@ -0,0 +1,10 @@
package com.fangjia.open;
public class test {
public static void main(String[] args) {
String a = "123545";
String b ="i980";
System.out.println(a.matches("\\d+"));
System.out.println(b.matches("\\d+"));
}
}
@@ -0,0 +1,18 @@
package com.fangjia;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.binary.Hex;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
while (true){
Scanner scanner = new Scanner(System.in);
String password = scanner.nextLine();
String p =DigestUtils.md5Hex(password);
System.out.println(p);
}
}
}
@@ -109,9 +109,11 @@
</div>
</div>
</div>
<div class="content-block">
<p><a href="../weiXinEvaluation/form?id=${id}" class="button button-big button-fill evaluation_btn external">房产评估</a></p>
</div>
<div class="content-block">
<p>
<a href="../weiXinEvaluation/form?id=${id}" class="button button-big button-fill evaluation_btn external">房产评估</a>
</p>
</div>
</#if>
</div>
</div>
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 KiB

@@ -21,12 +21,12 @@
</head>
<body>
<!-- 替换百盛图片 -->
<div class="page-group">
<div class="page page-current">
<div class="content login_bg2">
<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/9nf1iubwu6.jpg" style="width: 80%;height: 50px;margin: 30px auto;"></div>
<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/bh1.png" id="bannersDiv" style="width: 100%;height: 220px;"></div>
<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/baisheng_logo.jpg" style="width: 80%;height: 50px;margin: 30px auto;"></div>
<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/bs_bananer.jpg" id="bannersDiv" style="width: 100%;height: 220px;"></div>
<div class="login_content" style="margin-top: 8%;">
<div class="login_input" id="bhFrom">
<div class="inputInfo01">
+16
View File
@@ -537,6 +537,22 @@
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-address-purification</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.9</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
</dependencies>
</project>
@@ -28,7 +28,8 @@ import org.bson.types.ObjectId
class InsertMonitorSquareRentCalcCommandBatch extends BaseBatch {
public static final DSCollection SEAWEED_COLL = new DataStore("seaweed.db.fangjia.com", 27007).getCollection("fangjia.seaweed")
// public static final DSCollection SEAWEED_COLL = new DataStore("seaweed.db.fangjia.com", 27007).getCollection("fangjia.seaweed")
public static final DBCollection SEAWEED_COLL = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com")
public final static DBCollection COMMAND_COLL = new MongoClient("log.mongo.db.fangjia.com", 52002).getDB('fangjia_log').getCollection('calc_command')
public final static DBCollection SQMETRE_RENT_COLL = MongoUtils.getCollectionByName("fangjia", "sqmetre_rent", "mongo.db.fangjia.com", 27017)
public final static DBCollection REGION_COLL = MongoUtils.getCollectionByName("fangjia", "region_block", "mongo.db.fangjia.com", 27017)
@@ -215,7 +216,7 @@ class InsertMonitorSquareRentCalcCommandBatch extends BaseBatch {
DBObject query = new BasicDBObject()
query.put("city", city)
query.put("cat", "district")
query.put("visible", 0)
query.put("status", 0)
DBObject fields = new BasicDBObject()
fields.put("city", 1)
@@ -227,11 +228,9 @@ class InsertMonitorSquareRentCalcCommandBatch extends BaseBatch {
int tryTimes = 5
List<BasicDBObject> districts = new ArrayList<BasicDBObject>()
for(int i=0; i < tryTimes; i++) {
DSCursor cur = SEAWEED_COLL.find(query, fields).batchSize(5000)
def cur = SEAWEED_COLL.find(query, fields).batchSize(5000)
int totalCount = cur.count()
Iterator<DBObject> iter = cur.iterator()
while(iter.hasNext()) {
BasicDBObject dbo = (BasicDBObject)iter.next()
for(def dbo : cur) {
districts.add(dbo)
}
if(districts.size() == totalCount) {
@@ -29,7 +29,7 @@ class DealPriceDataProcess {
// task.process()//运当成交pe值不好时行,拉升成交价格及删除pe太大数据
// task.addLianJiaPrice();
task.deleteThirdPartyData()//删除第三方
task.delDealByPe()//删除成交
// task.delDealByPe()//删除成交
// task.delDealData()
// task.exportThirdParty()
@@ -37,8 +37,7 @@ class DealPriceDataProcess {
}
def delDealByPe(){
def yearMonth = 202312
def thirdMonth = 202112
def yearMonth = 202401
def rets = findAllDealByPe(yearMonth, 18)
@@ -52,7 +52,7 @@ class GuiDingPriceBatch extends BaseBatch{
def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city)
//添加自己库中的人工指导价
def prices = CcbCommonUtils.findPersonPrice(city, "2023-12-27", "2024-01-10")
def prices = CcbCommonUtils.findPersonPrice(city, "2024-01-10", "2024-01-28")
// def prices = CcbCommonUtils.findPersonPrice(city, "2022-01-01", "2022-11-22")
if(prices){
def distMap = getDistrictMap(city)
@@ -1288,7 +1288,7 @@ def findAvgPrice(def commid, def pgsqlInstance, def cityid){
def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20231222--修正人工指导价.xlsx"
def fileName = "D:\\数据\\建行\\房产估值\\指导价\\20240127.xlsx"
ExcelUtils.multiThreadingModify(fileName, {d->
if(d['A']){
@@ -1303,13 +1303,13 @@ ExcelUtils.multiThreadingModify(fileName, {d->
if(!d['I']){
def dist = CommonDatautils.findDistrictById(d['C'])
if(dist){
d['I'] = dist.region
d['F'] = dist.region
// d['H'] = dist.name
d['J'] = dist.status
if(d['A']=="天门" || d['A']=="迪庆"){
def val = d['E'].toString().toDouble().toInteger() + RandomUtil.random(-200,200)
d['K'] = val.toInteger()
}
d['G'] = dist.status
// if(d['A']=="天门" || d['A']=="迪庆"){
// def val = d['E'].toString().toDouble().toInteger() + RandomUtil.random(-200,200)
// d['K'] = val.toInteger()
// }
}
}
}
@@ -54,7 +54,7 @@ class ThirdPartyPriceBatch extends BaseBatch {
// ps.addBatch(id)
// }
// }
//
def citys = CcbCommonUtils.getRunningCitys(args)
def rows = []
def index = 0
@@ -93,13 +93,13 @@ class TradeStatLog {
def run(){
def citys = CcbCommonUtils.citys_all;
def rets = []
rets << ["城市","23年9月总量","23年10月总量","23年11月总量","占比","贝壳","链家", "我爱我家","幸福里APP","中原"]
rets << ["城市","23年10月总量","23年11月总量","23年12月总量","占比","贝壳","链家", "我爱我家","幸福里APP","中原"]
def sources = ["贝壳找房","链家在线","我爱我家","房天下","中原地产"]
//def startDate = "2021-05-01"
def startDate = "2023-09-01"
def date = "2023-10-01"
def endDate = "2023-11-01"
def newDate = "2023-12-01"
def startDate = "2023-10-01"
def date = "2023-11-01"
def endDate = "2023-12-01"
def newDate = "2024-01-01"
for(def city : citys){
def lastMonthCount = findTradesCount(city, null, DateUtils.parseFromTightByPattern(startDate,"yyyy-MM-dd"), DateUtils.parseFromTightByPattern(date,"yyyy-MM-dd"))
@@ -17,7 +17,7 @@ class ExportPgsqlBaseEvaluation {
def database = "base"
def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "28";
def linux_prefix = "/home/goojia/ccb_data/evaluation/"
def linux_prefix = "/home/goojia/ccb_data/evaluation/"
def win_prefix = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\evaluation\\${curDate}\\"
static main(args) {
@@ -4007,7 +4007,7 @@ class CommonDatautils {
}
static def findAmapDetailBySql(city){
String sql = "select * from amap_poi_detail where cityname='${city}' and status=0"
String sql = "select * from amap_poi where cityname='${city}' and status=0"
def rets = []
ElasticUtils.executeSqlQuery(sql,{data->
// if(data.name.contains('华山小区G栋')){
@@ -374,15 +374,18 @@ class OpenApiUtils {
}
static def searchBaiDuMap(String address, String region, int cityCode) {
static def searchBaiDuMap(String region, String township, String keyword,int cityCode) {
def rets = []
keyword = keyword.replace("居民委员会","").replace("居委会","").replace("居委会","").replace("居委","").replace("村民委员会","").replace("村村委会","村").replace("村委会","村")
def address = keyword
try {
Thread.sleep(500)
long t = System.currentTimeMillis()
// String url = "http://map.baidu.com/?newmap=1&reqflag=pcmap&biz=1&from=webmap&da_par=baidu&pcevaname=pc4.1" +
// "&qt=con&da_src=searchBox.button&wd="+URLEncoder.encode(address,"UTF-8")+"&c=${cityCode}&src=0&wd2=&sug=0&l=13" +
// "&sug_forward=&tn=B_NORMAL_MAP&nn=0&u_loc=13509900,3640104&ie=utf-8&t=${t}"
String url = "https://map.baidu.com/?newmap=1&reqflag=pcmap&biz=1&from=webmap&da_par=baidu&pcevaname=pc4.1&qt=s&da_src=searchBox.button&wd="+URLEncoder.encode(address,"UTF-8")+"&c=${cityCode}&src=0&wd2=&pn=0&sug=0&l=11&from=webmap&sug_forward=&auth=7dDde8w2f6QfKBaV88xOONTKIxBMTxbHuxHNLELRBNLt1qo6DF%3D%3DC1GgvPUDZYOYIZuVt1cv3uVtGccZcuVtPWv3GuztQZ3wWvUvhgMZSguxzBEHLNRTVtcEWe1GD8zv7u%40ZPuVteuztghxehwzJP4G46zzWvnrRR1aDcvY1SGpuxEtEjjg2e&device_ratio=1&tn=B_NORMAL_MAP&nn=0&u_loc=13509900,3640104&ie=utf-8&t=${t}";
// String url = "https://map.baidu.com/?newmap=1&reqflag=pcmap&biz=1&from=webmap&da_par=baidu&pcevaname=pc4.1&qt=s&da_src=searchBox.button&wd="+URLEncoder.encode(address,"UTF-8")+"&c=${cityCode}&src=0&wd2=&pn=0&sug=0&l=11&from=webmap&sug_forward=&auth=7dDde8w2f6QfKBaV88xOONTKIxBMTxbHuxHNLELRBNLt1qo6DF%3D%3DC1GgvPUDZYOYIZuVt1cv3uVtGccZcuVtPWv3GuztQZ3wWvUvhgMZSguxzBEHLNRTVtcEWe1GD8zv7u%40ZPuVteuztghxehwzJP4G46zzWvnrRR1aDcvY1SGpuxEtEjjg2e&device_ratio=1&tn=B_NORMAL_MAP&nn=0&u_loc=13509900,3640104&ie=utf-8&t=${t}";
String url = "https://map.baidu.com/?newmap=1&reqflag=pcmap&biz=1&from=webmap&da_par=baidu&pcevaname=pc4.1&qt=s&da_src=searchBox.button&wd="+URLEncoder.encode(address,"UTF-8")+"&src=0&wd2=&pn=0&sug=0&l=11&from=webmap&sug_forward=&auth=7dDde8w2f6QfKBaV88xOONTKIxBMTxbHuxHNLELRBNLt1qo6DF%3D%3DC1GgvPUDZYOYIZuVt1cv3uVtGccZcuVtPWv3GuztQZ3wWvUvhgMZSguxzBEHLNRTVtcEWe1GD8zv7u%40ZPuVteuztghxehwzJP4G46zzWvnrRR1aDcvY1SGpuxEtEjjg2e&device_ratio=1&tn=B_NORMAL_MAP&nn=0&u_loc=13509900,3640104&ie=utf-8&t=${t}";
def content = new HttpRequest().get(url, null, "utf-8")
JSONObject json = JSONObject.fromObject(content)
@@ -390,22 +393,46 @@ class OpenApiUtils {
for (def loc : json.content) {
String name = formatName(address)
if(loc.uid) {
JSONObject uidInfo = BaiDuApiUtils.getDetailByUid(loc.uid)
JSONObject uidInfo = null;//BaiDuApiUtils.getDetailByUid(loc.uid)
if(uidInfo != null) {
rets = createData(rets, uidInfo, loc, region, name, address)
}else{
def baiduRegion = loc.area_name.replace(loc.city_name,"")
def baiduCity = loc.city_name
if(baiduCity.contains("市")){
baiduCity = baiduCity.substring(0, baiduCity.indexOf("市"))
}
baiduCity = RegionData.formatCity(baiduCity)
def score1 = CosineSimilarAlgorithm.getSimilarityRatio(loc.name, address);
def score2 = CosineSimilarAlgorithm.getSimilarityRatio(loc.addr, address);
if(!baiduCity){
baiduCity = loc.history_address
if(baiduCity.contains("市")){
baiduCity = baiduCity.substring(0, baiduCity.indexOf("市"))
}
baiduCity = RegionData.formatCity(baiduCity)
}
if(!baiduCity){
baiduCity = loc.area_name
if(baiduCity.contains("市")){
baiduCity = baiduCity.substring(0, baiduCity.indexOf("市"))
}
baiduCity = RegionData.formatCity(baiduCity)
}
def baiduRegion = loc.area_name.replace(baiduCity,"")
keyword = keyword.replace("社区","")
def bdName = loc.name.replace("居民委员会","").replace("居委会","").replace("居委","").replace("村民委员会","").replace("村村委会","村").replace("村委会","村").replace("社区","")
def score1 = CosineSimilarAlgorithm.getSimilarityRatio(bdName, keyword);
def score2 = CosineSimilarAlgorithm.getSimilarityRatio(loc.addr, keyword);
if(score1 || score2){
def bean = [:]
bean.name = loc.name
bean.address = loc.addr.replace("[]","")
bean.city = baiduCity
bean.region = baiduRegion
bean.township = loc.admin_info.town_name
if(loc.admin_info){
bean.township = loc.admin_info.town_name
}
def locArrs = BaiduCoordinateConverter.bdMercator2Latlng(loc.diPointX/100.0, loc.diPointY/100.0)
if(locArrs){
def gmap = GeocodeUtils.geoconvBaiduToGoogle(locArrs[0], locArrs[1])
@@ -48,13 +48,13 @@ class YouDaDataParser {
def final AtomicInteger count_ = new AtomicInteger(0)
static def statDate = "2023-11-01"
static def statDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1),"yyyy-MM-dd")
static main(args) {
def task = new YouDaDataParser();
// task.newHouseparse();//友达一手房存入mongo
// task.esfParser("D:\\数据\\友达\\2023年12月\\查询1.DBF");//友达二手房存入mongo
task.esfParser("D:\\数据\\友达\\2024年1月\\查询1.DBF");//友达二手房存入mongo
// task.newhouseToSaveEs();//新房保存到es
task.esfhouseToSaveEs();//二手房保存到es
// task.esfhouseToSaveEs();//二手房保存到es
// task.updateFinishDateByEsfTrade();//根据二手成交的竣工时间修改seaweed库中的竣工时间
}
@@ -348,4 +348,24 @@ class FangjiaClientUtils {
return jsonObj;
}
public static def villageIdentify(city, address){
def jsonObj = null
def content = null
try {
address = address.replace("{","")
def url = "http://192.168.0.19:31080/FangJiaAddressService/villageIdentify?address="+URLEncoder.encode(address,"UTF-8")+"&type=2"
if(city){
url = url +"&city="+URLEncoder.encode(city,"UTF-8")
}
content = new HttpRequest().newGet(url, null, "utf-8")
jsonObj = JSONObject.fromObject(content)
println jsonObj
} catch (Exception e) {
println address +" "+content
e.printStackTrace();
}
return jsonObj;
}
}
@@ -0,0 +1,343 @@
package com.fangjia.script.gj.village
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.gj.village.ailiyun.SignatureUtils
import com.fangjia.script.util.CosineSimilarAlgorithm
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
import net.sf.json.JSONObject
import org.apache.commons.lang.StringUtils
import java.util.regex.Pattern
def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009";
DBCollection development_zone_CONN = MongoUtils.getCollectionByName2("fangjia", "development_zone", MONGO100_URL)
DBCollection community_CONN = MongoUtils.getCollectionByName2("fangjia", "community", MONGO100_URL)
def filePath = "D:\\数据\\光大\\全量.xlsx"
//ExcelUtils.modify(filePath, { row ->
// if(!row['O']){
// def jsonObj = FangjiaClientUtils.villageIdentify(null, row['A'])
// if(jsonObj && jsonObj.result){
// row['B'] = jsonObj.result.countyLevelCity
// if(row['B']){
// if(row['B']=="是"){
// row['C'] = "否"
// }else if(row['B']=="否"){
// row['C'] = "是"
// }
// }
// row['D'] = jsonObj.result.district
// row['E'] = jsonObj.result.districtCode
// if(jsonObj.result.administrativeTowns && jsonObj.result.administrativeTowns=="是"){
// row['F'] = jsonObj.result.administrativeTowns
// row['G'] = jsonObj.result.town
// row['H'] = jsonObj.result.townCode
// }
//
// if(jsonObj.result.countyGov && jsonObj.result.countyGov=="是"){
// row['I'] = jsonObj.result.countyGov
// row['J'] = jsonObj.result.town
// row['K'] = jsonObj.result.townCode
// }
//
// if(jsonObj.result.devDistrict && jsonObj.result.devDistrict=="是"){
// row['L'] = jsonObj.result.devDistrict
// row['M'] = jsonObj.result.devDistrictName
// }
// row['N'] = jsonObj.result.addrVerify
// row['O'] = jsonObj.result.province
// row['P'] = jsonObj.result.city
// row['Q'] = jsonObj.result.committee
// row['R'] = jsonObj.result.typeName
// row['S'] = jsonObj.result.splitCommittee
// row['T'] = jsonObj.result.splitStreet
// row['U'] = jsonObj.result.splitStreetNum
// row['V'] = jsonObj.result.poiName
// row['W'] = jsonObj.result.dev
// }
// }
def retMap = SignatureUtils.getAliAddressStrc(row['A'])
println row['A'] +" " + retMap.toString()
if(retMap){
row['Y'] = retMap.prov
row['Z'] = retMap.city
row['AA'] = retMap.district
row['AB'] = retMap.town
row['AC'] = retMap.devzone
row['AD'] = retMap.road
row['AE'] = retMap.roadno
row['AF'] = retMap.poi
row['AG'] = retMap.subpoi
}
// })
//ExcelUtils.multiThreadingModify(filePath, { row ->
//
// if(row['AA'] && !row['AO']){
// if(row['Y']){
// if(row['Y'].endsWith("区")){
// row['AE'] = "否"
// row['AF'] = "是"
// }else {
// row['AE'] = "是"
// row['AF'] = "否"
// }
// }
//
// if(row['AA']){
// def dev_name = isDev(development_zone_CONN, row['W'], row['X'], row['Y'], row['AA'])
// if(!dev_name && row['AA'].contains("经济开发区")){
// dev_name = row['AA'].replace("经济开发区","经济技术开发区")
// dev_name = isDev(development_zone_CONN, row['W'], row['X'], row['Y'], dev_name)
// }
// if(!dev_name && row['AA'].contains("经济技术开发区")){
// dev_name = row['AA'].replace("经济技术开发区","经济开发区")
// dev_name = isDev(development_zone_CONN, row['W'], row['X'], row['Y'], dev_name)
// }
// if(dev_name){
// row['AO'] = "是"
// row['AP'] = dev_name
// }
// }
//
// if(row['W'] && row['X'] && row['Y'] && row['Z']){
// def townObj = isTown(row['X'], row['Y'], row['Z'])
// if(townObj){
// row['AI'] = "是"
// row['AJ'] = row['Z']
// }
//
// def communityObj = findCommunityTown(community_CONN, row['X'], row['Y'], row['Z'])
// if(communityObj){
// row['AL'] = isGov(communityObj)
// if(row['AL'] && row['AL'] =="是"){
// row['AM'] = row['Z']
// row['AN'] = communityObj.street_code
// }
// row['AG'] = communityObj.area_name
// row['AH'] = communityObj.area_code
//
// if(row['AI'] && row['AI'] == "是"){
// row['AK'] = communityObj.street_code
// }
// }else{
// def towns = findAllTowns(community_CONN, row['X'], row['Y'])
// def retObj = findBestSimilar(row['Z'], towns)
// if(retObj && retObj.score>=0.5){
// row['AQ'] = retObj.name
// }
// }
// }
// }
//
//})
//ExcelUtils.multiThreadingModify(filePath, { row ->
// if(row['F'] && !row['T']){
// def q = new BasicDBObject()
// q.put("province", row['B'])
// def rets = development_zone_CONN.find(q).toList()
// def maxScore = 0;
// def map = [:]
// if(rets){
// for(def r : rets){
// def score1 = CosineSimilarAlgorithm.getSimilarityRatio(row['B']+row['C']+row['F'], r.name);
// if(score1>maxScore){
// map.name = r.name
// map.score = score1
// maxScore = score1
// }
// }
// if(map){
// row['W'] = map.name
// row['X'] = map.score
// }
// }
// }
//})
ExcelUtils.multiThreadingModify(filePath, { row ->
if(row['C'] && row['R']){
def obj = findFirstData(community_CONN, row['C'], row['D'], row['R'])
if(obj){
row['S'] = obj.street_code
}
}
})
def findBestSimilar(town, towns){
def map = [:];
def maxScore = 0
for(def name : towns){
def score1 = CosineSimilarAlgorithm.getSimilarityRatio(town, name);
if(score1>maxScore){
map.name = name
map.score = score1
maxScore = score1
}
}
return map
}
def isDev(development_zone_CONN, def prov, def city, def region, def dev){
def q = new BasicDBObject()
q.put("province", prov)
dev = dev.replace("(","").replace(")","").replace("市","")
if(dev.contains(region) && region.toString().endsWith("区")){
def newRegion = region.replace("区","")
dev = dev.replace(region, newRegion)
}
Pattern pattern = Pattern.compile('^.*' + dev + '.*$', Pattern.CASE_INSENSITIVE);
q.put("name",new BasicDBObject('$regex', pattern))
def rets = development_zone_CONN.find(q).toList()
def developmentZone = null
if(rets){
def devList = []
devList.add(dev);
try{
devList.add(region.replace("县","").replace("区","").replace("市","") + dev);
}catch(e){
println region +" "+ e.getMessage()
}
try{
devList.add(city.replace("市","") + region.replace("县","").replace("区","").replace("市","") + dev);
}catch(e){
println city+" "+region+" "+e.getMessage()
}
try{
devList.add(prov.replace("省","") + city.replace("市","")+ region.replace("县","").replace("区","").replace("市","") + dev);
}catch(e){
println prov+" "+city+" "+region+" "+e.getMessage()
}
try{
devList.add(city.replace("市","") + dev);
}catch(e){
println e
}
try{
devList.add(prov.replace("省","")+ city.replace("市","") + dev);
}catch(e){
println e
}
try{
devList.add(prov.replace("省","")+ region.replace("县","").replace("区","").replace("市","")+ dev);
}catch(e){
println e
}
devList.add(prov.replace("省","")+ dev);
for(def zone : rets){
String name = zone.name.replace("省","").replace("市","").replace("县","")
if(!name.endsWith("区")){
name = name.replace("区","");
}
if(devList.contains(name)){
developmentZone = zone;
break;
}
}
}
if(developmentZone){
return developmentZone.name;
}
return null;
}
def isTown( city, region, town){
// ElasticUtils.executeSqlQuery("select * from administrative_town where province = '${prov}' and city='${city}' and district='${region}' and town='${town}'", {
// obj = it
// },"192.168.0.89")
def header = [:]
header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString()
String seawaterUrl = "http://192.168.0.89:9200/administrative_town/_search"
def body = """
{
"query": {
"bool":{
"must":[
{"term": {"city.keyword":"${city}"}},
{"term": {"district.keyword":"${region}"}},
{"term": {"town.keyword":"${town}"}}
]
}
}
}
"""
HttpRequest request = new HttpRequest()
String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8")
def response = JSONObject.fromObject(res)
def obj = null
if(response && response.hits){
def hits = response.hits.hits
if(hits){
obj = hits[0]
}
}
println(response)
return obj
}
def findCommunityTown(community_CONN, city, region, town){
def q = new BasicDBObject()
q.put("city_name", city)
q.put("area_name", region)
Pattern pattern = Pattern.compile(town + '.*$', Pattern.CASE_INSENSITIVE);
q.put("street_name",new BasicDBObject('$regex', pattern))
def rets = community_CONN.find(q).toList()
def obj = null
if(rets){
obj = rets[0]
}
return obj;
}
def findAllTowns(community_CONN, city, region){
def q = new BasicDBObject()
q.put("city_name", city)
q.put("area_name", region)
def rets = community_CONN.find(q).toList()
def towns = []
for(def t : rets){
if(!towns.contains(t.street_name)){
towns << t.street_name
}
}
return towns;
}
def findFirstData(community_CONN, city, region, town){
def q = new BasicDBObject()
q.put("city_name", city)
q.put("area_name", region)
q.put("street_name", town)
def obj = community_CONN.findOne(q)
return obj
}
def isGov(obj){
String hasGovFlag = null;
if(obj){
hasGovFlag = obj.has_gov;
}
if(StringUtils.isNotBlank(hasGovFlag) && hasGovFlag.equals("是")){
return "是"
}else {
return "否"
}
}
@@ -0,0 +1,53 @@
package com.fangjia.script.gj.village.ailiyun
import com.aliyun.tea.*;
class AnliyunApiUtils {
/**
* 使用AK&SK初始化账号Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static com.aliyun.iot20180120.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,您的 AccessKey ID
.setAccessKeyId(accessKeyId)
// 必填,您的 AccessKey Secret
.setAccessKeySecret(accessKeySecret);
// Endpoint 请参考 https://api.aliyun.com/product/Iot
config.endpoint = "iot.cn-beijing.aliyuncs.com";
return new com.aliyun.iot20180120.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
// 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用,仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
com.aliyun.iot20180120.Client client = createClient(Config.accessKey, Config.accessKeySecret);
com.aliyun.iot20180120.models.CreateDeviceGroupRequest createDeviceGroupRequest = new com.aliyun.iot20180120.models.CreateDeviceGroupRequest()
.setIotInstanceId("your_value")
.setSuperGroupId("your_value")
.setGroupDesc("your_value")
.setGroupName("your_value");
try {
// 复制代码运行请自行打印 API 的返回值
client.createDeviceGroupWithOptions(createDeviceGroupRequest, new com.aliyun.teautil.models.RuntimeOptions());
} catch (TeaException error) {
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}
@@ -0,0 +1,14 @@
package com.fangjia.script.gj.village.ailiyun
/* 服务端API签名配置文件
*
* @author: ali
* @version: 0.1 2018-08-08 08:23:54
*/
public class Config {
// AccessKey信息
public static String accessKey = "LTAI5t7UKjXaoGxzet2Vh3bB";
public static String accessKeySecret = "2avjPxmI7FlIRHvMC5C1UuAnd9iG8z";
public final static String CHARSET_UTF8 = "utf8";
}
@@ -0,0 +1,203 @@
package com.fangjia.script.gj.village.ailiyun
import com.aliyuncs.CommonRequest
import com.aliyuncs.CommonResponse
import com.aliyuncs.DefaultAcsClient
import com.aliyuncs.IAcsClient
import com.aliyuncs.exceptions.ClientException
import com.aliyuncs.http.FormatType
import com.aliyuncs.http.MethodType
import com.aliyuncs.profile.DefaultProfile
import com.fangjia.core.util.DateUtil
import com.fangjia.core.util.HttpRequest
import net.sf.json.JSONObject
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder
import java.rmi.ServerException;
import java.util.Map;
import java.util.TreeMap;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
/**
* 服务端API签名
*
* @author: ali
* @version: 0.1 2018-06-21 20:47:05
*/
public class SignatureUtils {
private final static String CHARSET_UTF8 = "utf8";
private final static String ALGORITHM = "HmacSHA1";
private final static String SEPARATOR = "&";
public static Map<String, String> splitQueryString(String url)
throws URISyntaxException, UnsupportedEncodingException {
URI uri = new URI(url);
String query = uri.getQuery();
final String[] pairs = query.split("&");
TreeMap<String, String> queryMap = new TreeMap<String, String>();
for (String pair : pairs) {
final int idx = pair.indexOf("=");
final String key = idx > 0 ? pair.substring(0, idx) : pair;
if (!queryMap.containsKey(key)) {
queryMap.put(key, URLDecoder.decode(pair.substring(idx + 1), CHARSET_UTF8));
}
}
return queryMap;
}
public static String generate(String method, Map<String, String> parameter, String accessKeySecret)
throws Exception {
String signString = generateSignString(method, parameter);
System.out.println("signString---" + signString);
byte[] signBytes = hmacSHA1Signature(accessKeySecret + "&", signString);
String signature = newStringByBase64(signBytes);
System.out.println("signature----" + signature);
if ("POST".equals(method))
return signature;
return URLEncoder.encode(signature, "UTF-8");
}
public static String generateSignString(String httpMethod, Map<String, String> parameter) throws IOException {
TreeMap<String, String> sortParameter = new TreeMap<String, String>();
sortParameter.putAll(parameter);
String canonicalizedQueryString = UrlUtil.generateQueryString(sortParameter, true);
if (null == httpMethod) {
throw new RuntimeException("httpMethod can not be empty");
}
StringBuilder stringToSign = new StringBuilder();
stringToSign.append(httpMethod).append(SEPARATOR);
stringToSign.append(percentEncode("/")).append(SEPARATOR);
stringToSign.append(percentEncode(canonicalizedQueryString));
return stringToSign.toString();
}
public static String percentEncode(String value) {
try {
return value == null ? null
: URLEncoder.encode(value, CHARSET_UTF8).replace("+", "%20").replace("*", "%2A").replace("%7E",
"~");
} catch (Exception e) {
}
return "";
}
public static byte[] hmacSHA1Signature(String secret, String baseString) throws Exception {
if (StringUtils.isEmpty(secret)) {
throw new IOException("secret can not be empty");
}
if (StringUtils.isEmpty(baseString)) {
return null;
}
Mac mac = Mac.getInstance("HmacSHA1");
SecretKeySpec keySpec = new SecretKeySpec(secret.getBytes(CHARSET_UTF8), ALGORITHM);
mac.init(keySpec);
return mac.doFinal(baseString.getBytes(CHARSET_UTF8));
}
public static String newStringByBase64(byte[] bytes) throws UnsupportedEncodingException {
if (bytes == null || bytes.length == 0) {
return null;
}
return new String(Base64.encodeBase64(bytes, false), CHARSET_UTF8);
}
// public static void main(String[] a){
// Map<String, String> map = new HashMap<String, String>();
// Calendar calendar = Calendar.getInstance()
// def startTime = DateUtil.formatByPattern(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
// // 公共参数
// map.put("Format", "JSON");
// map.put("Version", "2019-11-18");
// map.put("AccessKeyId", Config.accessKey);
// map.put("SignatureMethod", "HMAC-SHA1");
// map.put("Timestamp", startTime);
// map.put("SignatureVersion", "1.0");
// map.put("SignatureNonce", System.currentTimeMillis().toString());
//// map.put("RegionId", "cn-shanghai");
// // 请求参数
// map.put("Action", "StreetStd");
// map.put("ServiceCode", "addrp");
// map.put("AppKey", "Xczmmbxlur2g");
// map.put("Text","山东省烟台市莱阳市龙门东路1号0027、0028")
// try {
// String signature = SignatureUtils.generate("GET", map, Config.accessKeySecret);
// if(signature){
// map.put("signature", signature);
// }
// String content = new HttpRequest().get("https://address-purification.cn-hangzhou.aliyuncs.com", map, "utf-8")
// JSONObject result = JSONObject.fromObject(content)
// System.out.println("最终signature: " + signature);
// } catch (Exception e) {
// e.printStackTrace();
// }
// System.out.println();
// }
public static def getAliAddressStrc(def address) {
DefaultProfile defaultProfile = DefaultProfile.getProfile(
"cn-hangzhou",
Config.accessKey,
Config.accessKeySecret);
IAcsClient client = new DefaultAcsClient(defaultProfile);
// 创建API请求并设置参数
CommonRequest request = new CommonRequest();
request.setSysDomain("address-purification.cn-hangzhou.aliyuncs.com");
request.setSysVersion("2019-11-18");
request.setSysProduct("address-purification");
request.setSysLocationProduct("addrp");
//设置要请求的服务
request.setSysAction("StreetStd");
//设置请求方式
request.setSysMethod(MethodType.POST);
request.setHttpContentType(FormatType.FORM);
//请求头
request.putHeadParameter("x-acs-signature-method", "HMAC-SHA1");
request.putHeadParameter("x-acs-signature-nonce", UUID.randomUUID().toString());
//设置项目token
request.putBodyParameter("AppKey", "Xczmmbxlur2g");
//设置请求参数
request.putBodyParameter("Text", address);
// request.putBodyParameter("DefaultCity", "杭州市");
request.putQueryParameter("AcceptLanguage", "zh-CN");
try {
CommonResponse response = client.getCommonResponse(request);
def data = response.getData();
def result = JSONObject.fromObject(data)
if(result && result.Data){
def data1 = JSONObject.fromObject(result.Data)
def std = data1.street_std
if(std){
def arrs = std.split("\t")
def map = [:]
for(def s : arrs){
def paramValues = s.split("=")
map.put(paramValues[0], paramValues[1])
}
return map
}
}
} catch (ServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,55 @@
package com.fangjia.script.gj.village.ailiyun
import java.net.URLEncoder;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
/**
* URL处理类
*
* @author: ali
* @version: 0.1 2018-06-21 20:40:52
*/
public class UrlUtil {
private final static String CHARSET_UTF8 = "utf8";
public static String urlEncode(String url) {
if (!StringUtils.isEmpty(url)) {
try {
url = URLEncoder.encode(url, "UTF-8");
} catch (Exception e) {
System.out.println("Url encode error:" + e.getMessage());
}
}
return url;
}
public static String generateQueryString(Map<String, String> params, boolean isEncodeKV) {
StringBuilder canonicalizedQueryString = new StringBuilder();
for (Map.Entry<String, String> entry : params.entrySet()) {
if (isEncodeKV)
canonicalizedQueryString.append(percentEncode(entry.getKey())).append("=")
.append(percentEncode(entry.getValue())).append("&");
else
canonicalizedQueryString.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
}
if (canonicalizedQueryString.length() > 1) {
canonicalizedQueryString.setLength(canonicalizedQueryString.length() - 1);
}
return canonicalizedQueryString.toString();
}
public static String percentEncode(String value) {
try {
// 使用URLEncoder.encode编码后,将"+","*","%7E"做替换即满足API规定的编码规范。
return value == null ? null
: URLEncoder.encode(value, CHARSET_UTF8).replace("+", "%20").replace("*", "%2A").replace("%7E",
"~");
} catch (Exception e) {
}
return "";
}
}
File diff suppressed because one or more lines are too long
@@ -1,11 +1,13 @@
package com.fangjia.script.gj.village
import com.fangjia.script.common.DataHandleUtils
import com.fangjia.script.gj.EsSearchUtils
import com.fangjia.script.looplineinfo.InsidePolygon
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.Bytes
import com.mongodb.DBCollection
DBCollection TOWN_POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "town_polyline")
@@ -13,43 +15,80 @@ DBCollection TOWN_POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia
def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009";
DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "community", MONGO100_URL)
def filePath = "D:\\数据\\涉农\\县.xlsx"
ExcelUtils.multiThreadingModify(filePath, { row ->
// if(!row['I']){
// def rets = EsSearchUtils.findPois(row['B'], row['C'], row['C']+"人民政府")
// if(rets){
// def obj = findOneByName(rets, row['C']+"人民政府")
// if(obj){
// row['I'] = obj.lng
// row['J'] = obj.lat
// println row['C'] + " "+obj
// }
// }
// }
// if(row['D'] && !row['F']){
// def townMap = findTownRange(row['B'], TOWN_POLYLINECOLL)
// def map = ["lon":row['D'], "lat":row['E']]
// def township = InsidePolygon.isInArea2(map.lon, map.lat, townMap)
// row['F'] = township
// }
//def s = getTownshipInfo("118.702988,39.740979")
def filePath = "D:\\数据\\涉农\\县政府(最终).xlsx"
//ExcelUtils.multiThreadingModify(filePath, { row ->
//// if(!row['I']){
//// def rets = EsSearchUtils.findPois(row['B'], row['C'], row['C']+"人民政府")
//// if(rets){
//// def obj = findOneByName(rets, row['C']+"人民政府")
//// if(obj){
//// row['I'] = obj.lng
//// row['J'] = obj.lat
//// println row['C'] + " "+obj
//// }
//// }
//// }
//
//// if(row['D'] && !row['F']){
//// def townMap = findTownRange(row['B'], TOWN_POLYLINECOLL)
//// def map = ["lon":row['D'], "lat":row['E']]
//// def township = InsidePolygon.isInArea2(map.lon, map.lat, townMap)
//// row['F'] = township
//// }
//
//// if(row['F'] && !row['J']){
//// def q = new BasicDBObject()
//// q.put("city_name", row['B'])
//// q.put("area_name", row['C'])
//// def streetName = row['F']
//// q.put("street_name", streetName)
//// def count = COMMUNITY_CONN.count(q);
//// row['J'] = count
////// row['H'] = streetName
//// }
//// if(!row['H']){
//// def gaodeMap = getTownshipInfo(row['D']+","+row['E'])
//// if(gaodeMap && gaodeMap.township){
//// row['H'] = gaodeMap.township
//// }
//// }
//
//// if(row['J'] && row['J'].toString().toDouble()>0){
//// def up_query = new BasicDBObject()
//// up_query.put("city_name", row['B'])
//// up_query.put("area_name", row['C'])
//// up_query.put("street_name", row['F'])
//// def udata = new BasicDBObject()
//// udata.put("has_gov", "是")
//// COMMUNITY_CONN.update(up_query, new BasicDBObject('$set', udata), false, true)
//// }
//
//
//})
if(row['F'] && !row['G']){
def q = new BasicDBObject()
q.put("city_name", row['B'])
q.put("area_name", row['C'])
def streetName = row['F']
q.put("street_name", streetName)
def count = COMMUNITY_CONN.count(q);
row['G'] = count
// row['H'] = streetName
def objs = COMMUNITY_CONN.find(new BasicDBObject()).setOptions(Bytes.QUERYOPTION_NOTIMEOUT);
for(def d : objs){
if(!d.name_pinyin){
if(d.name){
println d._id
def py1 = com.fangjia.core.util.DataUtil.hanyuQuanpin(d.name, " ")
def udata = new BasicDBObject()
udata.put("name_pinyin", py1)
if(d.location){
def lon = DataHandleUtils.getDoubleRound(6, d.location.lon)
def lat = DataHandleUtils.getDoubleRound(6, d.location.lat)
udata.put("location", ["lat":lat, "lon":lon])
}
def q = new BasicDBObject()
q.put("_id", d._id)
COMMUNITY_CONN.update(q, new BasicDBObject('$set', udata), false, true)
}
}
// def gaodeMap = getTownshipInfo(row['D']+","+row['E'])
// if(gaodeMap && gaodeMap.township){
// row['H'] = gaodeMap.township
// }
})
}
def getTownshipInfo(def glocation){
@@ -0,0 +1,47 @@
package com.fangjia.script.gj.village
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
import com.rabbitmq.client.impl.AMQImpl
import org.bson.types.ObjectId
def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009";
DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "community_new_2023", MONGO100_URL)
filePath = "D:\\Êý¾Ý\\ɿũ\\18Íò×îÖÕ-id.xlsx"
def index = 0
ExcelUtils.multiThreadingModify(filePath, { d->
if(d['A']){
def q = new BasicDBObject("_id", d['A'])
def dbo = COMMUNITY_CONN.findOne(q)
if(dbo){
index++
println index
COMMUNITY_CONN.remove(q)
}else{
// def udata = new BasicDBObject()
// udata.put("_id" , d['A'])
// udata.put("province" , d['A'])
// udata.put("province_code" , d['A'])
// udata.put("city_code" , d['A'])
// udata.put("area_name" , d['A'])
// udata.put("area_code" , d['A'])
// udata.put("street_name" , d['A'])
// udata.put("street_code" , d['A'])
// udata.put("name" , d['A'])
// udata.put("code" , d['A'])
// udata.put("type_code" , d['A'])
// udata.put("type_name" , d['A'])
// udata.put("location_type" , d['A'])
// udata.put("geohash" , d['A'])
// udata.put("location" , d['A'])
// udata.put("new_poi_name" , d['A'])
// udata.put("new_area_name" , d['A'])
// udata.put("city_name" , d['A'])
// COMMUNITY_CONN.save(udata);
}
}
})
@@ -4,6 +4,7 @@ import com.fangjia.core.RegionData
import com.fangjia.script.BaseBatch
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.common.DataHandleUtils
import com.fangjia.script.lixue.DB.City
import com.fangjia.script.looplineinfo.InsidePolygon
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.MongoUtils
@@ -25,7 +26,7 @@ class SuggestionDataSynch extends BaseBatch{
def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009";
DBCollection SEAWEED_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed", MONGO100_URL)
DBCollection administrative_division_100_CONN = MongoUtils.getCollectionByName2("fangjia", "administrative_division", MONGO100_URL)
DBCollection SUGGESTION_CONN = MongoUtils.getCollectionByName2("fangjia", "suggestion", MONGO100_URL)
DBCollection SUGGESTION_CONN = MongoUtils.getCollectionByName2("fangjia", "suggestion_new", MONGO100_URL)
DBCollection MAPPOI_CONN = MongoUtils.getCollectionByName2("fangjia", "map_poi", MONGO100_URL)
@@ -44,15 +45,29 @@ class SuggestionDataSynch extends BaseBatch{
static main(args) {
runBatch(new SuggestionDataSynch(), args);
}
@Override
public void process(Object args) {
run()
// updateCode()
// getExitsCity()
}
def getExitsCity(){
SUGGESTION_CONN = MongoUtils.getCollectionByName2("fangjia", "suggestion_new", MONGO100_URL)
def cities = SUGGESTION_CONN.distinct("city", new BasicDBObject("type","poi"))
def simpleCities = []
for (def c :cities) {
def city = RegionData.formatCity(c)
simpleCities.add(city)
}
// print(simpleCities)
return simpleCities
}
@@ -63,10 +78,14 @@ class SuggestionDataSynch extends BaseBatch{
def index = 0
fullCityMap = queryFullNameCity()
mcaDistMap = queryDistNameCity()
def existCities = getExitsCity()
for (def c : citys) {
def allRets = []
if(["上海","北京","广州","深圳","成都","杭州","天津","西安","南京","沈阳","重庆","武汉","石家庄","福州","宁波","贵阳","怀化","郴州","益阳","永州","娄底","湘西","长沙","常德","株洲","岳阳","衡阳","湘潭","张家界","邵阳","南京","苏州","无锡","扬州","常州","徐州","镇江","南通","泰州","连云港","盐城","淮安","宿迁"].contains(c)){
// if(["上海","北京","广州","深圳","成都","杭州","天津","西安","南京","沈阳","重庆","武汉","石家庄","福州","宁波","贵阳","怀化","郴州","益阳","永州","娄底","湘西","长沙","常德","株洲","岳阳","衡阳","湘潭","张家界","邵阳","南京","苏州","无锡","扬州","常州","徐州","镇江","南通","泰州","连云港","盐城","淮安","宿迁"].contains(c)){
if(existCities.contains(c)){
continue;
}
index++
@@ -100,12 +119,12 @@ class SuggestionDataSynch extends BaseBatch{
try{
count = SUGGESTION_CONN.count(q)
}catch(e){
SUGGESTION_CONN = MongoUtils.getCollectionByName2("fangjia", "suggestion", MONGO100_URL)
SUGGESTION_CONN = MongoUtils.getCollectionByName2("fangjia", "suggestion_new", MONGO100_URL)
count = SUGGESTION_CONN.count(q)
}
if(count>0){
SUGGESTION_CONN.remove(q)
}
// if(count>0){
// SUGGESTION_CONN.remove(q)
// }
def rets = []
for(def i=0;i<rows.size();i++){
@@ -0,0 +1,175 @@
package com.fangjia.script.majintao
import com.fangjia.core.RegionData
import com.fangjia.core.ProvinceData
import com.fangjia.core.util.MongoUtils
import com.fangjia.datastore.driver.DSCollection
import com.fangjia.datastore.driver.DataStore
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.ElasticUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
import org.bson.types.ObjectId
def map = [
["学校", "高等院校", "中学", "小学", "幼儿园", "成人教育", "职业技术学校"]: "学校",
["综合医院", "专科医院"] : "医院",
["银行"] : "银行",
["超级市场", "家电电子卖场", "便民商店/便利店"] : "超市",
["商场"] : "商场",
["美容美发店"] : "美容院",
["健身中心"] : "健身中心",
["公园广场", "公园"] : "公园/绿地",
["公交车站"] : "公交",
["飞机场"] : "机场",
["火车站"] : "火车站",
["快餐厅", "外国餐厅", "中餐厅"] : "餐馆",
["宾馆酒店", "旅馆招待所"] : "酒店"
] as HashMap<List<String>, String>
def type3In = ["学校", "高等院校", "中学", "小学", "幼儿园", "成人教育", "职业技术学校", "健身中心", "公园广场", "公园", "地铁站", "飞机场", "火车站"]
// 输出 Map 的内容
map.each { key, value ->
println("$key: $value")
}
def provinceList = []
def provinceMap = ProvinceData.data
provinceMap.each { pro ->
provinceList.add(pro.getValue()[0])
}
def cityMap = ProvinceData.GOVERNMENT_CITY_LIST
cityMap.each { city ->
provinceList.add(city.getValue()[0])
}
def specialMap = ProvinceData.SPECIAL_ADMIN_REGION
specialMap.each { spe ->
provinceList.add(spe.getValue()[1])
}
def pcmap = [:]
provinceList.remove("广西省")
provinceList.add("广西壮族自治区")
DSCollection seabird = new DataStore("192.168.0.43", 28017).getCollection("fangjia_base.baidu_place_poi2")
DBCollection m43 = MongoUtils.getCollectionByName("fangjia_base", "baidu_place_poi2", "192.168.0.43", 28017)
//def type3Not = ["学校内部设施", "进港", "出港", "候船室", "住宿服务相关"]
//
//def type2Not = ["学校", "专科医院", "综合医院", "诊所", "银行", "自动提款机", "便民商店/便利店", "家电电子卖场", "超级市场", "商场", "美容美发店", "地铁站", "港口码头", "住宿服务"]
//def type2In = ["运动场馆", "公园广场", "公交车站", "机场相关", "火车站", "餐饮服务"]
// 运动场馆 且为 健身中心
// 公园广场 公园广场
//公园广场 公园
// 公交车站 公交车站相关
// 机场相关 飞机场
// 火车站 火车站
// 餐饮服务 快餐厅 外国餐厅 中餐厅
println(provinceList)
//provinceList = provinceList.subList(0,1)
def c = 0
def citys = []
def citys2 = []
for (p in provinceList) {
println(p)
def result = []
ElasticUtils.executeSqlQuery("SELECT location,name,adname,cityname,m_date,id,address,type FROM amap_poi WHERE pname = '" + p + "'", { Map data ->
// println(data["type"] + "-----")
c = c+1
if (c%10000==0){
println("已处理$c 条")
}
def locationString = String.valueOf(data.get("location"))
def typeString = String.valueOf(data.get("type"))
def cityString = String.valueOf(data.get("cityname"))
// citys2.add(cityS)
// print(cityString)
String city
if ("台湾省".equals(cityString) | "香港特别行政区".equals(cityString) | "澳门特别行政区".equals(cityString)) {
city = cityString
} else {
city = RegionData.formatCity(cityString)
}
def m_date = data["m_date"]
def region = data["adname"]
region = RegionData.formatRegion(city,region)
def address = String.valueOf(data.get("address"))
def uid = String.valueOf(data.get("id"))
def name = data.get("name")
if (typeString.contains("|")) {
typeString = typeString.split("'|'")[0]
}
// println(typeString)
def secondType = typeString.split(";")[1]
def smallType = typeString.split(";")[2]
// println(smallType.getClass().getName())
// 使用正则表达式匹配经度和纬度
def matcher = locationString =~ /(-?\d+\.\d+)/
def keyword = ""
def flag = 0
// 类型映射
// 用三级分类判断
if (smallType in type3In) {
// 遍历Map的键集合,检查目标字符串是否存在于键集合中
map.keySet().each { key ->
if (key.contains(smallType)) {
def value = map[key]
// println("$smallType 存在于Map的键中,对应的值为: $value")
keyword = value
}
}
} else {
//用二级分类判断
map.keySet().each { key ->
if (key.contains(secondType)) {
def value = map[key]
// println("$secondType 存在于Map的键中,对应的值为: $value")
keyword = value
}
}
}
// 获取匹配到的经度和纬度值
def lng = matcher[0][0]
lng = lng.toDouble()
def lat = matcher[1][0]
lat = lat.toDouble()
// println "纬度: $lng, 经度: $lat,"
if (!"".equals(keyword)) {
def dbo = new BasicDBObject()
dbo["_id"] = new ObjectId()
dbo["keyword"] = keyword
dbo["lat"] = lat
dbo["name"] = name
dbo["city"] = city
dbo["m_date"] = m_date
dbo["lng"] = lng
dbo["c_date"] = m_date
dbo["address"] = address
dbo["uid"] = uid
dbo["status"] = 0
dbo["source"] = "gaode"
dbo["region"] = region
result.add(dbo)
}
// print(result)
// println("888")
})
if (null != result && result.size() > 0) {
m43.insert(result)
}
println("已处理完$p 的数据")
}
@@ -0,0 +1,25 @@
package com.fangjia.script.majintao
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.ElasticUtils
import com.mongodb.BasicDBObject
def count = 0
//ElasticUtils.executeSqlQuery("SELECT * FROM seawater WHERE city = '重庆' and region = '渝北' and district_name = '棕榈泉国际花园四期'and p_date > 20230801 ",{Map doc->
ElasticUtils.executeSqlQuery("SELECT * FROM seawater WHERE p_date > 20230801 order by p_date desc limit 100",{Map doc->
def keys = ["c_date","_id","cat","city","region","name","address","block","district_name","total_price","area","height","floor","fitment","estate_type","hall","toilet","publish_date","url","direction","build_type","pay_type","line","rent_type","status","room"]
// def dbo = new BasicDBObject()
// for( String key in keys){
// dbo[key] = doc[key]
// }
// println(doc['m_date'])
// print(doc['name'])
if (count==0)print(doc)
count+=1
// DbUtils.seabird.save(dbo)
})
//DbUtils.seabird.find(new BasicDBObject("district_name","棕榈泉国际花园四期")).each {
// println(it)
//}
print(count)
@@ -7,26 +7,26 @@ import jxl.Sheet
import jxl.Workbook
import org.apache.poi.ss.usermodel.WorkbookFactory
String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表 - 副本.xlsx"
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
province1 = items['A']
if (!province1.equals('黑龙江省') || !province1.equals('内蒙古自治区')) {
province = province1.substring(0, 2)
} else {
province = province1.substring(0, 3)
}
println('province: ' + province)
def citys = ProvinceData.getAllCity(province)
println(citys)
if (citys.size() > 0) {
ExcelUtils.writeToExcel(excelFilePath, citys, province)
}
})
//String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表 - 副本.xlsx"
//ExcelUtils.removeEmptyRow(excelFilePath)
//ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
//
// province1 = items['A']
// if (!province1.equals('黑龙江省') || !province1.equals('内蒙古自治区')) {
// province = province1.substring(0, 2)
// } else {
// province = province1.substring(0, 3)
// }
//
// println('province: ' + province)
//
// def citys = ProvinceData.getAllCity(province)
// println(citys)
//// if (citys.size() > 0) {
//// ExcelUtils.writeToExcel(excelFilePath, citys, province)
//// }
//
//})
//
@@ -0,0 +1,72 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.gj.village.ailiyun.SignatureUtils
import com.fangjia.script.util.ExcelUtils
//def address = "江苏省徐州市贾汪区经济开发区大黄山镇孤山小区B3.801"
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
def count = 0
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
count = count + 1
if (count % 10 == 0) {
println("已处理:" + count)
}
sleep(50)
def address = items['A']
def map = SignatureUtils.getAliAddressStrc(address)
//prov=河南省 city=信阳市 district=息县 town=孙庙乡 community=前赵楼村 road=前赵楼村 poi=爱婆店 roomno=012
if ("prov" in map) {
def province = map.get("prov")
items['D'] = province
}
if ("city" in map) {
def city = map.get("city")
items['H'] = city
}
if ("district" in map) {
def district = map.get("district")
items['L'] = district
}
if ("town" in map) {
def town = map.get("town")
items['P'] = town
}
if ("community" in map) {
def community = map.get("community")
items['T'] = community
}
// if ("road" in map) {
// def road = map.get("road")
// items['G'] = road
//
// }
// if ("poi" in map) {
//
// def poi = map.get("poi")
// items['H'] = poi
//
// }
// if ("roomno" in map) {
// def roomno = map.get("roomno")
// items['I'] = roomno
//
// }
// if ("devzone" in map) {
// def devzone = map.get("devzone")
// items['J'] = devzone
//
// }
// if ("roadno" in map) {
// def roadno = map.get("roadno")
// items['K'] = roadno
// }
})
@@ -0,0 +1,76 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.gj.village.ailiyun.SignatureUtils
import com.fangjia.script.util.ExcelUtils
//def address = "江苏省徐州市贾汪区经济开发区大黄山镇孤山小区B3.801"
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
def count = 0
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
count = count + 1
if (count % 10 == 0) {
println("已处理:" + count)
}
sleep(50)
def address = items['A']
def pro = items['D']
if (pro == null) {
def map = SignatureUtils.getAliAddressStrc(address)
//prov=河南省 city=信阳市 district=息县 town=孙庙乡 community=前赵楼村 road=前赵楼村 poi=爱婆店 roomno=012
if ("prov" in map) {
def province = map.get("prov")
items['D'] = province
}
if ("city" in map) {
def city = map.get("city")
items['H'] = city
}
if ("district" in map) {
def district = map.get("district")
items['L'] = district
}
if ("town" in map) {
def town = map.get("town")
items['P'] = town
}
if ("community" in map) {
def community = map.get("community")
items['T'] = community
}
// if ("road" in map) {
// def road = map.get("road")
// items['G'] = road
//
// }
// if ("poi" in map) {
//
// def poi = map.get("poi")
// items['H'] = poi
//
// }
// if ("roomno" in map) {
// def roomno = map.get("roomno")
// items['I'] = roomno
//
// }
// if ("devzone" in map) {
// def devzone = map.get("devzone")
// items['J'] = devzone
//
// }
// if ("roadno" in map) {
// def roadno = map.get("roadno")
// items['K'] = roadno
// }
}
})
@@ -0,0 +1,64 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\ÁÙʱÊý¾Ý\\2.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
String url = "http://192.168.0.19:31080/FangJiaAddressService/v3/structure";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String address = items['A']
def map = [:]
map.put("address", address)
map.put("complete", "true")
map.put("addressAssessment", "true")
def content = httpRequest.getJsonContent(url, map, "UTF-8")
def result = content.get("result")
if ("province" in result) {
items['B'] = result.get("province")
}
if ("provinceCode" in result) {
items['C'] = result.get("provinceCode")
}
if ("city" in result){
items['D'] = result.get("city")
}
if("cityCode" in result){
items['E'] = result.get("cityCode")
}
if ("district" in result){
items['F'] = result.get("district")
}
if ("districtCode" in result){
items['G'] = result.get("districtCode")
}
if ("township" in result){
items['H'] = result.get("township")
}
if ("townshipCode" in result){
items['I'] = result.get("townshipCode")
print(result.get("townshipCode"))
}
if ("address" in result){
items['J'] = result.get("address")
}
if ("formatAddress" in result){
items['K'] = result.get("formatAddress")
}
})
@@ -0,0 +1,124 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
def count = 0
ExcelUtils.multiThreadingModify(excelFilePath, { List items ->
count += 1
if (count % 10 == 0) {
println("已处理:" + count)
}
String address = items['A']
String province = items['B']
if (province == null) {
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
def map = [:]
map.put("address", address)
map.put("complete", "true")
map.put("addressAssessment", "true")
map.put("type", "1")
def content = httpRequest.getJsonContent(url, map, "UTF-8")
def result = content.get("result")
if (result != null) {
if ("province" in result) {
items['B'] = result.get("province")
}
if ("provinceCode" in result) {
items['C'] = result.get("provinceCode")
}
if ("city" in result) {
items['D'] = result.get("city")
}
if ("cityCode" in result) {
items['E'] = result.get("cityCode")
}
if ("district" in result) {
items['F'] = result.get("district")
}
if ("districtCode" in result) {
items['G'] = result.get("districtCode")
}
if ("town" in result) {
items['H'] = result.get("town")
}
if ("townCode" in result) {
items['I'] = result.get("townCode")
}
if ("committee" in result) {
items['J'] = result.get("committee")
}
if ("committeeCode" in result) {
items['K'] = result.get("committeeCode")
}
if ("typeCode" in result) {
items['L'] = result.get("typeCode")
}
if ("typeName") {
items['M'] = result.get("typeName")
}
if ("verifyFlag") {
items['N'] = result.get("verifyFlag")
}
if ("addrVerify") {
items['O'] = result.get("addrVerify")
}
if ("countyLevelCity") {
items['P'] = result.get("countyLevelCity")
}
if ("countyGov") {
items['Q'] = result.get("countyGov")
}
if ("communitySource") {
items['R'] = result.get("communitySource")
}
if ("administrativeTowns" in result) {
items['T'] = result.get("administrativeTowns")
}
if ("devDistrict" in result) {
items['V'] = result.get("devDistrict")
}
if ("devDistrictName" in result) {
items['W'] = result.get("devDistrictName")
}
if ("splitCommittee" in result) {
items['X'] = result.get("splitCommittee")
}
if ("splitStreet" in result) {
items['Y'] = result.get("splitStreet")
}
if ("poiName" in result) {
items['Z'] = result.get("poiName")
}
if ("splitStreetNum" in result) {
items['AA'] = result.get("splitStreetNum")
}
if ("dev" in result) {
items['AB'] = result.get("dev")
}
}
}
})
@@ -0,0 +1,147 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\对公.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
def count = 0
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
count+=1
if (count%10==0){
println("已处理:"+count)
}
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String address = items['A']
// print(address)
// province;
// city;
// district;
// town;
// committee;
// type;
// provinceCode;
// cityCode;
// districtCode;
// townCode;
// committeeCode;
// typeCode;
// typeName;
// verifyFlag;//涉农标识
// addrVerify;//地址是否有效信息
// countyLevelCity;//是否为县级市
// administrativeTowns;//是否市辖建制镇
// countyGov;//是否为县政府
// devDistrict;//是否为开发区
// devDistrictName;//开发区
// splitCommittee;
// splitStreet;
// poiName;
// splitStreetNum;
// dev;
// communitySource;//居委来源
def map = [:]
map.put("address", address)
map.put("complete", "true")
map.put("addressAssessment", "true")
map.put("type", "2")
def content = httpRequest.getJsonContent(url, map, "UTF-8")
def result = content.get("result")
if ("province" in result) {
items['B'] = result.get("province")
}
if ("provinceCode" in result) {
items['C'] = result.get("provinceCode")
}
if ("city" in result){
items['D'] = result.get("city")
}
if("cityCode" in result){
items['E'] = result.get("cityCode")
}
if ("district" in result){
items['F'] = result.get("district")
}
if ("districtCode" in result){
items['G'] = result.get("districtCode")
}
if ("town" in result){
items['H'] = result.get("town")
}
if ("townCode" in result){
items['I'] = result.get("townCode")
}
if ("committee" in result){
items['J'] = result.get("committee")
}
if ("committeeCode" in result){
items['K'] = result.get("committeeCode")
}
if ("typeCode" in result){
items['L'] = result.get("typeCode")
}
if ("typeName"){
items['M'] = result.get("typeName")
}
if ("verifyFlag"){
items['N'] = result.get("verifyFlag")
}
if ("addrVerify"){
items['O'] = result.get("addrVerify")
}
if ("countyLevelCity"){
items['P'] = result.get("countyLevelCity")
}
if ("countyGov"){
items['Q'] = result.get("countyGov")
}
if ("communitySource"){
items['R'] = result.get("communitySource")
}
if ("administrativeTowns" in result){
items['T'] = result.get("administrativeTowns")
}
if ("devDistrict" in result){
items['V'] = result.get("devDistrict")
}
if ("devDistrictName" in result){
items['W'] = result.get("devDistrictName")
}
if ("splitCommittee" in result){
items['X'] = result.get("splitCommittee")
}
if ("splitStreet" in result){
items['Y'] = result.get("splitStreet")
}
if ("poiName" in result){
items['Z'] = result.get("poiName")
}
if ("splitStreetNum" in result){
items['AA'] = result.get("splitStreetNum")
}
if ("dev" in result){
items['AB'] = result.get("dev")
}
})
@@ -0,0 +1,44 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据 - 副本.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
def count = 0
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
count += 1
if (count % 10 == 0) {
println("已处理:" + count)
}
String flag = items['X']
String address = items['A']
String tt = items['Y']
if (flag == null&&"地址有效".equals(tt)) {
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
def map = [:]
map.put("address", address)
map.put("complete", "true")
map.put("addressAssessment", "true")
map.put("type", "1")
def content = httpRequest.getJsonContent(url, map, "UTF-8")
def result = content.get("result")
if (result != null) {
if ("verifyFlag" in result) {
items['X'] = result.get("verifyFlag")
}
}
}
})
@@ -0,0 +1,121 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
String excelFilePath = "C:\\Users\\Goojia\\Desktop\\ÄϾ©ÒøÐвâÊÔ.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
def count = 0
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
count+=1
if (count%10==0){
println("ÒÑ´¦Àí£º"+count)
}
String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String address = items['A']
def map = [:]
map.put("address", address)
map.put("complete", "true")
map.put("addressAssessment", "true")
map.put("type", "2")
def content = httpRequest.getJsonContent(url, map, "UTF-8")
def result = content.get("result")
if ("province" in result) {
items['B'] = result.get("province")
}
if ("provinceCode" in result) {
items['C'] = result.get("provinceCode")
}
if ("city" in result){
items['D'] = result.get("city")
}
if("cityCode" in result){
items['E'] = result.get("cityCode")
}
if ("district" in result){
items['F'] = result.get("district")
}
if ("districtCode" in result){
items['G'] = result.get("districtCode")
}
if ("town" in result){
items['H'] = result.get("town")
}
if ("townCode" in result){
items['I'] = result.get("townCode")
}
if ("committee" in result){
items['J'] = result.get("committee")
}
if ("committeeCode" in result){
items['K'] = result.get("committeeCode")
}
if ("typeCode" in result){
items['L'] = result.get("typeCode")
}
if ("typeName"){
items['M'] = result.get("typeName")
}
if ("verifyFlag"){
items['N'] = result.get("verifyFlag")
}
if ("addrVerify"){
items['O'] = result.get("addrVerify")
}
if ("countyLevelCity"){
items['P'] = result.get("countyLevelCity")
}
if ("countyGov"){
items['Q'] = result.get("countyGov")
}
// if ("communitySource"){
// items['R'] = result.get("communitySource")
// }
//
// if ("administrativeTowns" in result){
// items['T'] = result.get("administrativeTowns")
// }
// if ("devDistrict" in result){
// items['V'] = result.get("devDistrict")
// }
// if ("devDistrictName" in result){
// items['W'] = result.get("devDistrictName")
// }
// if ("splitCommittee" in result){
// items['X'] = result.get("splitCommittee")
// }
// if ("splitStreet" in result){
// items['Y'] = result.get("splitStreet")
// }
// if ("poiName" in result){
// items['Z'] = result.get("poiName")
// }
// if ("splitStreetNum" in result){
// items['AA'] = result.get("splitStreetNum")
// }
// if ("dev" in result){
// items['AB'] = result.get("dev")
// }
})
@@ -0,0 +1,72 @@
package com.fangjia.script.majintao.test
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy1.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
String comprehensiveUrl = "http://localhost:9180/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
String caseUrl = "http://open.fangjia.com/house/case";
String poiUrl = "http://open.fangjia.com/district/addrFacilitys";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String city = items['A']
String address = items['B']
double size = items['C']
System.out.println(city + "---" + address + "----" + size);
map.put("city", city)
map.put("address", address)
map.put("size", size.toString())
map.put("strctureArea", size.toString())
map.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB")
if (!address.contains("%")) {
// 发送HTTP请求
long start
long end
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(communityUrl, map, "UTF-8")
//
//
// end = System.currentTimeMillis();
// items['D'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(valueUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['E'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(caseUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['F'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(poiUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['G'] = String.valueOf(end - start);
start = System.currentTimeMillis();
def content = httpRequest.getJsonContent(comprehensiveUrl, map, "UTF-8")
end = System.currentTimeMillis();
items['H'] = String.valueOf(end - start);
println content.get("msg")
if(content.get("msg").contains("该地址不支持估价!")) {
items['I'] = "该地址不支持估价!"
}
}
})
@@ -1,54 +1,4 @@
package com.fangjia.script.majintao
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject
String excelFilePath = "F:\\估家\\文件\\北交所\\暂时不能估值数据 - 副本.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
String comprehensiveUrl = "http://open.fangjia.com/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
String caseUrl = "http://open.fangjia.com/house/case";
String poiUrl = "http://open.fangjia.com/district/addrFacilitys";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String city = items['A']
String address = items['B']
double size = items['C']
System.out.println(city + "---" + address + "----" + size);
map.put("city", city)
map.put("address", address)
map.put("size", size.toString())
map.put("strctureArea", size.toString())
map.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB")
if (!address.contains("%")) {
// 发送HTTP请求
long start
long end
def addressValue = httpRequest.getJsonContent(communityUrl, map, "UTF-8")
items['D'] = addressValue.get('result').toString()
def value = httpRequest.getJsonContent(valueUrl, map, "UTF-8")
items['E'] = value.get('result').toString()
def houseCase = httpRequest.getJsonContent(caseUrl, map, "UTF-8")
items['F'] = houseCase.get('result').toString()
def poi = httpRequest.getJsonContent(poiUrl, map, "UTF-8")
items['G'] = poi.get('result').toString()
}
})
import org.bson.types.ObjectId
a = new ObjectId()
print(a)
@@ -23,8 +23,8 @@ class DataStat {
// for(def city :citys){
// println city
// }
task.run();
// task.stat()
// task.run();
task.stat()
// def citys = ["¸£ÖÝ", "ÏÃÃÅ", "ȪÖÝ", "ÆÎÌï", "ÄþµÂ", "ÈýÃ÷", "ÁúÑÒ", "ÄÏÆ½", "ÕÄÖÝ"]
// def rets = []
@@ -76,12 +76,8 @@ class DataStat {
}
def stat(){
def dates = [201810,201811,201812,201901,201902,201903,201904,201905,201906,201907,201908,201909]
def sources = ["时间","房估估","诸葛找房","安居客","搜房","中原地产","赶集",
"链家","兔博士","城市房产","贝壳找房","Q房","乐有家",
"房探","房多多","小资家","我爱我家","麦田","房途",
"C21","乐居","房产超市","58同城"]
def dates = [202301,202302,202303,202304,202305,202306,202307,202308,202309,202310,202311,202401]
def sources = ["时间","我爱我家","兔博士","吉屋","贝壳找房","乐有家","365淘房","诸葛找房","链家","Q房","麦田","中原地产","安居客","搜房","C21","城市房产","幸福里"]
// crawlCount(dates,sources);
matchCount(dates,sources);
}
@@ -12,10 +12,10 @@ class TestCrawlTotalCount {
task.run();
}
def run(){
def sources = ["房估估","诸葛找房","安居客","搜房","中原地产","赶集","链家","兔博士","城市房产","贝壳找房","Q房","Q房(新)","中原地产(新)","乐有家","乐有家(新)","房探","房多多","小资家","我爱我家","麦田","房途","C21","乐居","房产超市","58同城","365淘房","吉屋"]
def sources = ["房估估","诸葛找房","安居客","搜房","中原地产","赶集","链家","兔博士","城市房产","贝壳找房","Q房","Q房(新)","中原地产(新)","乐有家","乐有家(新)","房探","房多多","小资家","我爱我家","麦田","房途","C21","乐居","房产超市","58同城","365淘房","吉屋","幸福里"]
for(def source :sources){
def count1 = findTotalCount(source, 202302);
def count2 = findTotalCount(source, 202303);
def count1 = findTotalCount(source, 202307);
def count2 = findTotalCount(source, 202401);
println source +" "+count1 +" "+count2
}
}
@@ -46,8 +46,11 @@ class ElasticUtils {
EsDataSource dataSource = new EsDataSource ();
dataSource.setUrl("jdbc:es://${host}:9200?timezone=UTC&page.size=240&connect.timeout=240000&network.timeout=60000&page.timeout=240000&query.timeout=90000");
Properties connectionProperties = new Properties();
connectionProperties.setProperty("user","developer");
connectionProperties.setProperty("password","5e8edd851d2fdfbd7415232c67367cc3");
// connectionProperties.setProperty("user","developer");
// connectionProperties.setProperty("password","5e8edd851d2fdfbd7415232c67367cc3");
connectionProperties.setProperty("user","elastic");
connectionProperties.setProperty("password","goojia123456");//elasticsearch
dataSource.setProperties(connectionProperties);
return dataSource;
}
@@ -454,7 +454,7 @@ public class ExcelUtils{
def data = ExcelUtils.read(fileName, srcSheetIndex, 0)
def body = data.subList(1, data.size())
def nThread = Runtime.getRuntime().availableProcessors() * 3
def nThread = 10
println nThread
ExecutorService executorService = Executors.newFixedThreadPool(3)
final AtomicInteger counter = new AtomicInteger(0)
@@ -299,6 +299,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
selectedSample.add(querySamples.get(i));
}
fillOthersInfo(selectedSample);
// 将最终样本进行排序
sortForSample(selectedSample, target);
List<Sample> sampleList = new ArrayList<Sample>(selectedSample.size());
for (SampleWrapper sampleWrapper : selectedSample) {
@@ -2747,11 +2747,14 @@ public class DistrictServiceImpl implements DistrictService {
public Integer getCreateYear(District district) {
Integer buildYear = getYearFormDate(district.getCreateYear());
int minYear = Integer.MAX_VALUE;
if (buildYear != null && buildYear < minYear) {
minYear = buildYear;
// int minYear = Integer.MAX_VALUE;
if (buildYear != null && buildYear < Integer.MAX_VALUE) {
// minYear = buildYear;
return buildYear;
}else {
return null;
}
return minYear;
// return minYear;
}
public Integer getBuildYear(District district) {
@@ -0,0 +1,17 @@
package com.fangjia.service.mongo.fangjia;
import com.fangjia.dal.mongo.model.AdministrativeDivision;
/**
* Created by ideoj on 2016/9/5.
*/
public interface AdministrativeDivisionService {
/**
* 根据code获取城市
* @param code
* @return
*/
AdministrativeDivision findcityByCode(String code);
}
@@ -0,0 +1,20 @@
package com.fangjia.service.mongo.fangjia;
import com.fangjia.dal.mongo.dao.AdministrativeDivisionDao;
import com.fangjia.dal.mongo.model.AdministrativeDivision;
public class AdministrativeDivisionServiceImpl implements AdministrativeDivisionService{
private AdministrativeDivisionDao administrativeDivisionDao;
@Override
public AdministrativeDivision findcityByCode(String code) {
return administrativeDivisionDao.findcityByCode(code);
}
public void setAdministrativeDivisionDao(AdministrativeDivisionDao administrativeDivisionDao) {
this.administrativeDivisionDao = administrativeDivisionDao;
}
}
@@ -61,5 +61,6 @@ public interface ApiUserService {
* @return
*/
User findUserById(Long id);
void clearApiUserAuthorityCache(long userId);
}