Merge branch 'master' of http://gitlab.fangjia.com/dev0/main into script_gj

# Conflicts:
#	projects/fangjia-script/src/main/groovy/com/fangjia/script/Watcher.groovy
This commit is contained in:
2024-02-28 16:29:01 +08:00
60 changed files with 6910 additions and 4962 deletions
@@ -11,6 +11,26 @@
<script type="text/javascript"> <script type="text/javascript">
</script> </script>
<#-- 将表头固定-->
<style>
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
position: sticky;
top: 0;
background-color: #f2f2f2;
}
</style>
</head> </head>
<body> <body>
@@ -31,12 +51,13 @@
<div class="list"> <div class="list">
<table width="50%"> <table width="50%">
<thead> <thead>
<tr>Ap <tr>
API数量:&nbsp<b>${authorityBoList?size}</b>个
<th align="center" width="15%"> <th align="center" width="15%">
uri uri
</th> </th>
<th align="center" width="15%"> <th align="center" width="15%">
描述 API名称
</th> </th>
<th align="center" width="10%"> <th align="center" width="10%">
是否有权限<input type="checkbox" id="auth" >全选</input> 是否有权限<input type="checkbox" id="auth" >全选</input>
@@ -63,7 +84,7 @@
${bo.uri!} ${bo.uri!}
</td> </td>
<td align="center"> <td align="center">
${bo.description!} ${bo.name!}
</td> </td>
<td align="center"> <td align="center">
<input type="checkbox" <#if bo.hasAuth>checked </#if> id="auth_${bo_index + 1}" ></input> <input type="checkbox" <#if bo.hasAuth>checked </#if> id="auth_${bo_index + 1}" ></input>
@@ -43,10 +43,20 @@
<input id="userId" name="userId" value="${userId!}" type="hidden"/> <input id="userId" name="userId" value="${userId!}" type="hidden"/>
<td>${apiUserBo.userName!}<#if (apiUserBo.displayName??)>(${apiUserBo.displayName!})</#if></td> <td>${apiUserBo.userName!}<#if (apiUserBo.displayName??)>(${apiUserBo.displayName!})</#if></td>
</tr> </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> <tr>
<td>密码</td> <td>
<td><input id="resetPwd" type="button" value="重置密码"/></td> &nbsp;&nbsp;&nbsp;&nbsp;<a href="../apiUser/editPwd?userId=${apiUserBo.userId!}">修改密码</a>
</td>
</tr> </tr>
<tr> <tr>
<td>账户类型</td> <td>账户类型</td>
<td> <td>
@@ -151,15 +161,15 @@
return re.test(strIP) return re.test(strIP)
} }
$("#resetPwd").click(function () { // $("#resetPwd").click(function () {
if (confirm('确认重置密码为【123456】?')) { // if (confirm('确认重置密码为【123456】?')) {
$.get('resetPwd', // $.get('resetPwd',
"userId=" + $("#userId").val(), // "userId=" + $("#userId").val(),
function (data) { // function (data) {
alert(status); // alert(status);
}) // })
} // }
}) // })
</script> </script>
</body> </body>
</html> </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>
@@ -1,14 +1,41 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
<#compress> <#compress>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head> <html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>api用户列表</title> <title>api用户列表</title>
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}" /> <link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}"/>
<#include "/common_js.ftl" /> <#include "/common_js.ftl" />
</head>
<body> <#-- 将表头固定-->
<style>
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
position: sticky;
top: 0;
background-color: #f2f2f2;
}
.resizable-td {
resize: horizontal; /* 允许水平调整大小 */
overflow: auto; /* 显示滚动条以便查看超出部分 */
min-width: 50px; /* 设置最小宽度,防止过于缩小 */
}
</style>
</head>
<body>
<#include "/layout/header.ftl" /> <#include "/layout/header.ftl" />
<div class="main-content"> <div class="main-content">
<font color="red">${msg!''}</font> <font color="red">${msg!''}</font>
@@ -44,7 +71,7 @@
<th align="center" width="100px"> <th align="center" width="100px">
公司 公司
</th> </th>
<th align="center" width="550px"> <th align="center" width="150px">
appKey appKey
</th> </th>
<th align="center" width="60px"> <th align="center" width="60px">
@@ -98,7 +125,7 @@
<td align="center"> <td align="center">
${bo.company!} ${bo.company!}
</td> </td>
<td align="center"> <td align="center" class="resizable-td">
${bo.appKey!} ${bo.appKey!}
</td> </td>
<td align="center"> <td align="center">
@@ -130,13 +157,15 @@
</#if> </#if>
</td> </td>
<td align="center"> <td align="center">
<a href="../apiUser/auth?userId=${bo.userId!}">权限控制</a> <a href="../apiUser/auth?userId=${bo.userId!}">API权限控制</a>
<a href="../apiUser/auth?userId=${bo.userId!}&msg=0">新增API</a>
<a href="../apiUser/city?userId=${bo.userId!}">城市管理</a> <a href="../apiUser/city?userId=${bo.userId!}">城市管理</a>
<a href="../apiUser/priceRating?userId=${bo.userId!}">价格评级</a> <a href="../apiUser/priceRating?userId=${bo.userId!}">价格评级</a>
<#if bo.status==0> <#if bo.status==0>
<a href="javascript:if(confirm('确认禁用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=1'}">禁用</a> <a href="javascript:if(confirm('确认禁用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=1'}">禁用</a>
<#else> <#else>
<a href="javascript:if(confirm('确认再次启用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=0'}"><font style="color:#198B3D;">再启用</font></a> <a href="javascript:if(confirm('确认再次启用?')){location.href='../apiUser/status?userId=${bo.userId!}&status=0'}"><font
style="color:#198B3D;">再启用</font></a>
</#if> </#if>
</td> </td>
</tr> </tr>
@@ -145,6 +174,6 @@
</table> </table>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
</#compress> </#compress>
@@ -8,6 +8,25 @@
.up {color: green;} .up {color: green;}
#spinner{width:500px;height:100px;margin:30px 0 0 100px;text-align:center;padding-top:50px;border:2px solid #CCC;} #spinner{width:500px;height:100px;margin:30px 0 0 100px;text-align:center;padding-top:50px;border:2px solid #CCC;}
#checkMsg{width:500px;margin:30px 0 0 100px;padding:10px 0 10px 50px;text-align:left;border:2px solid #CCC;} #checkMsg{width:500px;margin:30px 0 0 100px;padding:10px 0 10px 50px;text-align:left;border:2px solid #CCC;}
<#-- 将表头固定-->
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
position: sticky;
top: 0;
background-color: #f2f2f2;
}
</style> </style>
</head> </head>
<body> <body>
@@ -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"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
BasicModel basicModel = new BasicModel(200, "ok"); 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)); basicModel.setResult(CommonDtoUtils.transformV(MatchedBuildingDto.class, json));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -284,16 +284,16 @@ public class AddrSvcController {
//新匹配接口 //新匹配接口
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
BasicModel basicModel = new BasicModel(200, "ok"); 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); 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) { if (null != district) {
DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName())); DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName()));
if(null != statBo){ if (null != statBo) {
if(statBo.getDistrictStat()!=null){ if (statBo.getDistrictStat() != null) {
dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice()); dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice());
}else if(statBo.getVillaDistrictStat()!=null){ } else if (statBo.getVillaDistrictStat() != null) {
dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice()); dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice());
} }
@@ -310,6 +310,102 @@ public class AddrSvcController {
return mav; 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) { public void setDistrictStatService(DistrictStatService districtStatService) {
this.districtStatService = districtStatService; this.districtStatService = districtStatService;
} }
@@ -113,9 +113,9 @@ public class AddressController {
private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3";
/** /**
* @deprecated see parse2Action
* @param model * @param model
* @return * @return
* @deprecated see parse2Action
*/ */
@Authority(role = Role.USER) @Authority(role = Role.USER)
public Object parseAction(AddressModel model) { public Object parseAction(AddressModel model) {
@@ -163,7 +163,7 @@ public class AddressController {
} }
@Authority(role = Role.USER) @Authority(role = Role.USER)
public Object analyzeAction(AddressModel model){ public Object analyzeAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView(); RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getCity())) { if (StringUtils.isBlank(model.getCity())) {
mav.setModel(BasicModel.buildBadRequestModel("城市不能为空")); mav.setModel(BasicModel.buildBadRequestModel("城市不能为空"));
@@ -481,9 +481,10 @@ public class AddressController {
/** /**
* 地址匹配第二个版本,基于第一个版本的逻辑,对匹配出的结果进行正确性的判断 * 地址匹配第二个版本,基于第一个版本的逻辑,对匹配出的结果进行正确性的判断
* @author yinjihuan *
* @param model * @param model
* @return * @return
* @author yinjihuan
*/ */
@Authority(role = Role.USER) @Authority(role = Role.USER)
public Object matchV2Action(AddesssMatchModel model) { public Object matchV2Action(AddesssMatchModel model) {
@@ -569,7 +570,7 @@ public class AddressController {
} }
} }
} }
} catch(Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
if (matchedVillage == false) { if (matchedVillage == false) {
@@ -970,7 +971,7 @@ public class AddressController {
return ret; return ret;
} }
private JSONObject addTerm(String name, String value){ private JSONObject addTerm(String name, String value) {
JSONObject term = new JSONObject(); JSONObject term = new JSONObject();
JSONObject match = new JSONObject(); JSONObject match = new JSONObject();
match.put(name, value); match.put(name, value);
@@ -978,7 +979,7 @@ public class AddressController {
return term; return term;
} }
private JSONObject addMatchPhrase(String name, String value){ private JSONObject addMatchPhrase(String name, String value) {
JSONObject term = new JSONObject(); JSONObject term = new JSONObject();
JSONObject match = new JSONObject(); JSONObject match = new JSONObject();
match.put(name, value); match.put(name, value);
@@ -1007,20 +1008,20 @@ public class AddressController {
query.put("bool", bool); query.put("bool", bool);
reqBody.put("query", query); reqBody.put("query", query);
Base64 token = new Base64(); Base64 token = new Base64();
String authenticationEncoding = token.encodeAsString((""+ES_USER+":"+ES_PASSWORD+"").getBytes()); String authenticationEncoding = token.encodeAsString(("" + ES_USER + ":" + ES_PASSWORD + "").getBytes());
HttpRequest request = new HttpRequest(); HttpRequest request = new HttpRequest();
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json"); headers.put("Content-Type", "application/json");
headers.put("Authorization", "Basic "+authenticationEncoding+""); headers.put("Authorization", "Basic " + authenticationEncoding + "");
try { try {
String response = request.postWithBody("http://192.168.0.45:9200/village/_search", reqBody, headers, "UTF-8"); String response = request.postWithBody("http://192.168.0.45:9200/village/_search", reqBody, headers, "UTF-8");
JSONObject json = JSONObject.fromObject(response); JSONObject json = JSONObject.fromObject(response);
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) {
return Collections.emptyList(); return Collections.emptyList();
} }
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
List<JSONObject> results = new ArrayList<JSONObject>(); List<JSONObject> results = new ArrayList<JSONObject>();
for(int i=0 ;i < hits.size(); i++){ for (int i = 0; i < hits.size(); i++) {
JSONObject jsonObject = hits.getJSONObject(i); JSONObject jsonObject = hits.getJSONObject(i);
results.add(jsonObject); results.add(jsonObject);
} }
@@ -1683,8 +1684,7 @@ public class AddressController {
/** /**
* 地址评级 * 地址评级
* *
* @param model * @param model (city+address)+addressId
* (city+address)+addressId
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址", * @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址",
* "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat": * "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat":
* 经纬度, "lng": 经纬度, "name": "匹配POIName", "score": 评分 }, "type": "可能存在" } * 经纬度, "lng": 经纬度, "name": "匹配POIName", "score": 评分 }, "type": "可能存在" }
@@ -1719,8 +1719,7 @@ public class AddressController {
/** /**
* 地址反欺诈 (地址验真+周边查询) * 地址反欺诈 (地址验真+周边查询)
* *
* @param model * @param model (city+address)+addressId
* (city+address)+addressId
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址", * @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址",
* "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat": * "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat":
* 纬度, "lng": 经度, "name": "匹配POIName", "poiList":[ { "name" : * 纬度, "lng": 经度, "name": "匹配POIName", "poiList":[ { "name" :
@@ -1757,8 +1756,7 @@ public class AddressController {
/** /**
* 地址反欺诈 (地址验真+周边查询) * 地址反欺诈 (地址验真+周边查询)
* *
* @param model * @param model (city+address)+addressId
* (city+address)+addressId
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": * @return { "code": 200, "msg": "ok", "result": { "data": { "address":
* "德州路220弄小区", "addressId": "d525e60aab2e84909d2fd998b0af5e8e", "city": * "德州路220弄小区", "addressId": "d525e60aab2e84909d2fd998b0af5e8e", "city":
* "上海市", "keyWords": "德州路220弄", "keyWordsUse": "德州路220弄", "lat": * "上海市", "keyWords": "德州路220弄", "keyWordsUse": "德州路220弄", "lat":
@@ -1809,7 +1807,7 @@ public class AddressController {
int code = json.getInt("code"); int code = json.getInt("code");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -1839,12 +1837,12 @@ public class AddressController {
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity()); params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
params.put("address", model.getAddress()); params.put("address", model.getAddress());
params.put("showCode", model.getShowCode()); params.put("showCode", model.getShowCode());
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
} catch(Exception e){
try { try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
} catch(Exception ex){ } catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -1853,7 +1851,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -1877,12 +1875,12 @@ public class AddressController {
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity()); params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
params.put("address", model.getAddress()); params.put("address", model.getAddress());
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
} catch(Exception e){
try { try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
} catch(Exception ex){ } catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -1891,7 +1889,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -1922,12 +1920,12 @@ public class AddressController {
params.put("address", model.getAddress()); params.put("address", model.getAddress());
// 地址验证无效也输出标准化结果 // 地址验证无效也输出标准化结果
params.put("flag", "true"); params.put("flag", "true");
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
} catch(Exception e){
try { try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
} catch(Exception ex){ } catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -1936,7 +1934,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -1967,12 +1965,12 @@ public class AddressController {
params.put("address", model.getAddress()); params.put("address", model.getAddress());
// 地址验证无效也输出标准化结果 // 地址验证无效也输出标准化结果
params.put("flag", "true"); params.put("flag", "true");
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
} catch(Exception e){
try { try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
} catch(Exception ex){ } catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -1981,7 +1979,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -1991,6 +1989,7 @@ public class AddressController {
return mav; return mav;
} }
/** /**
* 详细地址标准化接口 * 详细地址标准化接口
* *
@@ -2012,12 +2011,12 @@ public class AddressController {
params.put("address", model.getAddress()); params.put("address", model.getAddress());
// 地址验证无效也输出标准化结果 // 地址验证无效也输出标准化结果
params.put("flag", "true"); params.put("flag", "true");
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
} catch(Exception e){
try { try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
} catch(Exception ex){ } catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -2026,7 +2025,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -2038,6 +2037,7 @@ public class AddressController {
/** /**
* 地址标准化专用测试接口 * 地址标准化专用测试接口
*
* @param model * @param model
* @return * @return
*/ */
@@ -2056,12 +2056,12 @@ public class AddressController {
params.put("address", model.getAddress()); params.put("address", model.getAddress());
// 地址验证无效也输出标准化结果 // 地址验证无效也输出标准化结果
params.put("flag", "true"); params.put("flag", "true");
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
} catch(Exception e){
try { try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8"); json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
} catch(Exception ex){ } catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -2070,7 +2070,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -2082,6 +2082,7 @@ public class AddressController {
/** /**
* 地址信息分类接口 * 地址信息分类接口
*
* @param model * @param model
* @return * @return
*/ */
@@ -2095,7 +2096,7 @@ public class AddressController {
HttpRequest request = new HttpRequest(); HttpRequest request = new HttpRequest();
JSONObject json = null; JSONObject json = null;
try{ try {
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json"); headers.put("Content-Type", "application/json");
@@ -2107,15 +2108,15 @@ public class AddressController {
reqBody.put("housePurpose", model.getHousePurpose()); reqBody.put("housePurpose", model.getHousePurpose());
reqBody.put("memo", model.getMemo()); reqBody.put("memo", model.getMemo());
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/communitySummary", reqBody ,headers, "UTF-8"); String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/communitySummary", reqBody, headers, "UTF-8");
if(result != null){ if (result != null) {
try{ try {
json = JSONObject.fromObject(result); json = JSONObject.fromObject(result);
} catch(Exception e){ } catch (Exception e) {
json = null; json = null;
} }
} }
} catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -2123,7 +2124,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -2135,6 +2136,7 @@ public class AddressController {
/** /**
* 楼盘评级 * 楼盘评级
*
* @param model * @param model
* @return * @return
*/ */
@@ -2148,7 +2150,7 @@ public class AddressController {
HttpRequest request = new HttpRequest(); HttpRequest request = new HttpRequest();
JSONObject json = null; JSONObject json = null;
try{ try {
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json"); headers.put("Content-Type", "application/json");
@@ -2160,14 +2162,14 @@ public class AddressController {
reqBody.put("housePurpose", model.getHousePurpose()); reqBody.put("housePurpose", model.getHousePurpose());
reqBody.put("memo", model.getMemo()); reqBody.put("memo", model.getMemo());
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/buildingRating", reqBody, headers, "UTF-8"); String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/buildingRating", reqBody, headers, "UTF-8");
if(result != null){ if (result != null) {
try{ try {
json = JSONObject.fromObject(result); json = JSONObject.fromObject(result);
} catch(Exception e){ } catch (Exception e) {
json = null; json = null;
} }
} }
} catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -2175,7 +2177,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -2187,20 +2189,21 @@ public class AddressController {
/** /**
* 财力评级 * 财力评级
*
* @param model * @param model
* @return * @return
*/ */
public Object financialRatingAction(CommunitySummaryRequestDto model) { public Object financialRatingAction(CommunitySummaryRequestDto model) {
RestfulModelAndView mav = new RestfulModelAndView(); RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress())) { if (StringUtils.isBlank(model.getAddress()) || "null".equals(model.getAddress())) {
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
return mav; return mav;
} }
HttpRequest request = new HttpRequest(); HttpRequest request = new HttpRequest();
JSONObject json = null; JSONObject json = null;
try{ try {
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json"); headers.put("Content-Type", "application/json");
@@ -2211,15 +2214,15 @@ public class AddressController {
reqBody.put("maxFloor", model.getMaxFloor()); reqBody.put("maxFloor", model.getMaxFloor());
reqBody.put("housePurpose", model.getHousePurpose()); reqBody.put("housePurpose", model.getHousePurpose());
reqBody.put("memo", model.getMemo()); reqBody.put("memo", model.getMemo());
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/financialRating", reqBody, headers,"UTF-8"); String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/financialRating", reqBody, headers, "UTF-8");
if(result != null){ if (result != null) {
try{ try {
json = JSONObject.fromObject(result); json = JSONObject.fromObject(result);
} catch(Exception e){ } catch (Exception e) {
json = null; json = null;
} }
} }
} catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -2227,7 +2230,7 @@ public class AddressController {
int code = json.getInt("status"); int code = json.getInt("status");
String msg = json.getString("msg"); String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg); BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){ if (json.containsKey("result")) {
basicModel.setResult(json.get("result")); basicModel.setResult(json.get("result"));
} }
mav.setModel(basicModel); mav.setModel(basicModel);
@@ -2317,26 +2320,26 @@ public class AddressController {
dto.append("township", address.getTownship()); dto.append("township", address.getTownship());
dto.append("street", address.getStreet()); dto.append("street", address.getStreet());
dto.append("streetNumber", address.getStreetNumber()); dto.append("streetNumber", address.getStreetNumber());
if(StringUtils.isBlank(building.getSuggestName())){ if (StringUtils.isBlank(building.getSuggestName())) {
if(StringUtils.isNotBlank(address.getParsedPropertyName())){ if (StringUtils.isNotBlank(address.getParsedPropertyName())) {
dto.append("name", address.getParsedPropertyName()); dto.append("name", address.getParsedPropertyName());
}else if(StringUtils.isNotBlank(address.getOrgKeywords())){ } else if (StringUtils.isNotBlank(address.getOrgKeywords())) {
dto.append("name", address.getOrgKeywords()); dto.append("name", address.getOrgKeywords());
} }
}else{ } else {
dto.append("name", building.getSuggestName()); dto.append("name", building.getSuggestName());
} }
if(StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())){ if (StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())) {
String addr = building.getAddress(); String addr = building.getAddress();
String street = AddressParserUtil.extractStreet(addr); String street = AddressParserUtil.extractStreet(addr);
if(street != null){ if (street != null) {
dto.append("street", street); dto.append("street", street);
if(addr.length() != street.length()){ if (addr.length() != street.length()) {
dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr)); dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr));
} }
}else if(StringUtils.isNotBlank(building.getStreet())){ } else if (StringUtils.isNotBlank(building.getStreet())) {
dto.append("street", building.getStreet()); dto.append("street", building.getStreet());
if(StringUtils.isNotBlank(building.getStreetno())){ if (StringUtils.isNotBlank(building.getStreetno())) {
dto.append("streetNumber", building.getStreetno()); dto.append("streetNumber", building.getStreetno());
} }
} }
@@ -2346,7 +2349,7 @@ public class AddressController {
dto.append("unitNumber", address.getUnitNumber()); dto.append("unitNumber", address.getUnitNumber());
dto.append("roomNumber", address.getRoomNumber()); dto.append("roomNumber", address.getRoomNumber());
dto.append("formattedAddress", address.getFormattedAddress()); dto.append("formattedAddress", address.getFormattedAddress());
if(matchParams.isContainsLocation()){ if (matchParams.isContainsLocation()) {
dto.append("lat", building.getLat()); dto.append("lat", building.getLat());
dto.append("lng", building.getLng()); dto.append("lng", building.getLng());
} }
@@ -2772,7 +2775,7 @@ public class AddressController {
check.setScore(score); check.setScore(score);
check.setScoreIncity(null); check.setScoreIncity(null);
check.setScoreInnation(null); check.setScoreInnation(null);
}else if(GRADE_CONSUME.equals(type)) { } else if (GRADE_CONSUME.equals(type)) {
check.setScoreIncity(null); check.setScoreIncity(null);
check.setScoreInnation(null); check.setScoreInnation(null);
check.setAreaScore(null); check.setAreaScore(null);
@@ -3099,7 +3102,7 @@ public class AddressController {
tr.setScore(score); tr.setScore(score);
tr.setScoreIncity(null); tr.setScoreIncity(null);
tr.setScoreInnation(null); tr.setScoreInnation(null);
}else if(GRADE_CONSUME.equals(type)) { } else if (GRADE_CONSUME.equals(type)) {
tr.setScoreIncity(null); tr.setScoreIncity(null);
tr.setScoreInnation(null); tr.setScoreInnation(null);
tr.setAreaScore(null); tr.setAreaScore(null);
@@ -3173,6 +3176,7 @@ public class AddressController {
/** /**
* 地址线下消费评级 * 地址线下消费评级
*
* @param model * @param model
* @return * @return
*/ */
@@ -3236,9 +3240,10 @@ public class AddressController {
/** /**
* 地址周边消费评级接口 * 地址周边消费评级接口
* <p>通过用户输入的地址,得到该地址的经纬度,找到该地址附近的三个非商住小区的小区消费评级评分,取一个平均分。<p> * <p>通过用户输入的地址,得到该地址的经纬度,找到该地址附近的三个非商住小区的小区消费评级评分,取一个平均分。<p>
* @author yinjihuyan *
* @param model * @param model
* @return * @return
* @author yinjihuyan
*/ */
public Object aroundConsumeGradeAction(AddressModel model) { public Object aroundConsumeGradeAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView(); RestfulModelAndView mav = new RestfulModelAndView();
@@ -3353,7 +3358,7 @@ public class AddressController {
LOGGER.error("风险识别出错:" + ex.getMessage(), ex); LOGGER.error("风险识别出错:" + ex.getMessage(), ex);
} }
resultMap.put("riskLevel","C"); resultMap.put("riskLevel", "C");
resultModel.setResult(resultMap); resultModel.setResult(resultMap);
mav.setModel(resultModel); mav.setModel(resultModel);
return mav; return mav;
@@ -3372,20 +3377,20 @@ public class AddressController {
query.put("bool", bool); query.put("bool", bool);
reqBody.put("query", query); reqBody.put("query", query);
Base64 token = new Base64(); Base64 token = new Base64();
String authenticationEncoding = token.encodeAsString((""+ES_USER+":"+ES_PASSWORD+"").getBytes()); String authenticationEncoding = token.encodeAsString(("" + ES_USER + ":" + ES_PASSWORD + "").getBytes());
HttpRequest request = new HttpRequest(); HttpRequest request = new HttpRequest();
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json"); headers.put("Content-Type", "application/json");
headers.put("Authorization", "Basic "+authenticationEncoding+""); headers.put("Authorization", "Basic " + authenticationEncoding + "");
try { try {
String response = request.postWithBody("http://192.168.0.45:9200/association/_search", reqBody, headers, "UTF-8"); String response = request.postWithBody("http://192.168.0.45:9200/association/_search", reqBody, headers, "UTF-8");
JSONObject json = JSONObject.fromObject(response); JSONObject json = JSONObject.fromObject(response);
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) {
return Collections.emptyList(); return Collections.emptyList();
} }
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
List<JSONObject> results = new ArrayList<JSONObject>(); List<JSONObject> results = new ArrayList<JSONObject>();
for(int i=0 ;i < hits.size(); i++){ for (int i = 0; i < hits.size(); i++) {
JSONObject jsonObject = hits.getJSONObject(i); JSONObject jsonObject = hits.getJSONObject(i);
results.add(jsonObject); results.add(jsonObject);
} }
@@ -1,18 +1,16 @@
package com.fangjia.open.controllers; package com.fangjia.open.controllers;
import com.fangjia.core.util.*; import com.fangjia.core.util.*;
import com.fangjia.dal.mongo.model.AdministrativeDivision;
import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.mongo.fangjia.model.ServerArea; import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.ApiUserCfg; import com.fangjia.dal.mongo.model.ApiUserCfg;
import com.fangjia.dal.mongo.model.DistrictFacilitys; import com.fangjia.dal.mongo.model.DistrictFacilitys;
import com.fangjia.dal.mongo.model.Evaluation; 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.model.bkoff.Loudong;
import com.fangjia.dal.mongo.open.model.ApiUserAuthority; import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
import com.fangjia.dal.mongo.open.model.EvaluateRatio; import com.fangjia.dal.mongo.open.model.EvaluateRatio;
import com.fangjia.dal.seaweed.model.District; 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.HouseValueInformationDto;
import com.fangjia.open.dto.UniversalDto; import com.fangjia.open.dto.UniversalDto;
import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; 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.bkoff.LoudongService;
import com.fangjia.service.mongo.fangjia.*; import com.fangjia.service.mongo.fangjia.*;
import com.fangjia.service.open.*; import com.fangjia.service.open.*;
import com.fangjia.service.tool.OpenLogService;
import com.fangjia.service.web.AddressService; import com.fangjia.service.web.AddressService;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
@@ -84,6 +81,7 @@ public class ComprehensiveQueryController {
static final int BAI_DU_GEO = 1;// 百度系坐标 static final int BAI_DU_GEO = 1;// 百度系坐标
static final int GAO_DE_GEO = 2;// 高德系坐标 static final int GAO_DE_GEO = 2;// 高德系坐标
private AdministrativeDivisionService administrativeDivisionService;
private EvaluateRatioService evaluateRatioService; private EvaluateRatioService evaluateRatioService;
@@ -213,11 +211,22 @@ public class ComprehensiveQueryController {
HouseValueInformationDto houseValueInformation = new HouseValueInformationDto(); HouseValueInformationDto houseValueInformation = new HouseValueInformationDto();
RestfulModelAndView mav = new RestfulModelAndView(); RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(String.valueOf(model.getSize()))) { if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(String.valueOf(model.getSize()))) {
mav.setModel(BasicModel.buildBadRequestModel("城市(city),地址(address),面积(size)为必填字段")); mav.setModel(BasicModel.buildBadRequestModel("地址(address),面积(size)为必填字段"));
return mav; 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(); HttpRequest httpRequest = new HttpRequest();
JSONObject json = null; JSONObject json = null;
Map<String, String> communityAvgPriceParams = new HashMap<String, String>(); Map<String, String> communityAvgPriceParams = new HashMap<String, String>();
@@ -228,10 +237,11 @@ public class ComprehensiveQueryController {
JSONObject matchResponse = null; JSONObject matchResponse = null;
try { try {
matchResponse = httpRequest.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8"); matchResponse = httpRequest.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8");
// matchResponse = httpRequest.getJsonContent("http://192.168.0.19:31080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8");
} catch (HttpRequestException e) { } 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("该地址不支持估价!")); mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
return mav; return mav;
} }
@@ -266,6 +276,8 @@ public class ComprehensiveQueryController {
district = bieShuDistrict; district = bieShuDistrict;
} }
} }
//添加城市
propertyEvaluationModel.setCity(district.getCity());
propertyEvaluationModel.setDistrict(district.getRegion()); propertyEvaluationModel.setDistrict(district.getRegion());
propertyEvaluationModel.setName(district.getName()); propertyEvaluationModel.setName(district.getName());
try { try {
@@ -286,7 +298,7 @@ public class ComprehensiveQueryController {
// RestfulModelAndView houseCaseMav = new RestfulModelAndView(); // RestfulModelAndView houseCaseMav = new RestfulModelAndView();
List<CollateralSampleQueryBean> querys = null; List<CollateralSampleQueryBean> querys = null;
try { try {
querys = convertSampileQueryToBean(district,sampleQuery); querys = convertSampileQueryToBean(district, sampleQuery);
} catch (Exception e) { } catch (Exception e) {
mav.setModel(BasicModel.buildBadRequestModel(e.getMessage())); mav.setModel(BasicModel.buildBadRequestModel(e.getMessage()));
return mav; return mav;
@@ -298,7 +310,7 @@ public class ComprehensiveQueryController {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<Collateral> collaterals = czbankSampleService.findSample2(querys, sampleQuery.getMax()); List<Collateral> collaterals = czbankSampleService.findSample2(querys, sampleQuery.getMax());
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
System.out.println("用时:"+(end-start)); System.out.println("用时:" + (end - start));
Collateral collateral = collaterals.get(0); Collateral collateral = collaterals.get(0);
List<Sample> samples = collateral.getSample(); List<Sample> samples = collateral.getSample();
UniversalDto houseCaseDto = UniversalDto.newDto(); UniversalDto houseCaseDto = UniversalDto.newDto();
@@ -425,7 +437,7 @@ public class ComprehensiveQueryController {
return propertyModel; 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); List<CollateralSampleQueryBean> queryBeans = new ArrayList<CollateralSampleQueryBean>(queries.length);
for (SampleQuery q : queries) { for (SampleQuery q : queries) {
@@ -497,10 +509,10 @@ public class ComprehensiveQueryController {
throws NumberFormatException, IllegalAccessException { throws NumberFormatException, IllegalAccessException {
// RestfulModelAndView mav = new RestfulModelAndView(); // RestfulModelAndView mav = new RestfulModelAndView();
// mav.setViewType("rest"); // mav.setViewType("rest");
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) if (StringUtils.isBlank(model.getName())
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) {
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); mav.setModel(BasicModel.buildBadRequestModel("参数非法:区域,小区名,面积(size)为必填项"));
return mav; // return mav;
} }
if (model.getCity().endsWith("市")) { if (model.getCity().endsWith("市")) {
model.setCity(model.getCity().replaceAll("市$", "")); model.setCity(model.getCity().replaceAll("市$", ""));
@@ -1229,8 +1241,6 @@ public class ComprehensiveQueryController {
} }
public void setEvaluationService(EvaluationService evaluationService) { public void setEvaluationService(EvaluationService evaluationService) {
this.evaluationService = evaluationService; this.evaluationService = evaluationService;
} }
@@ -1253,7 +1263,6 @@ public class ComprehensiveQueryController {
} }
public BatchEvaluateService getBatchEvaluateService() { public BatchEvaluateService getBatchEvaluateService() {
return batchEvaluateService; return batchEvaluateService;
} }
@@ -1312,5 +1321,8 @@ public class ComprehensiveQueryController {
this.districtFacilitysService = districtFacilitysService; this.districtFacilitysService = districtFacilitysService;
} }
public void setAdministrativeDivisionService(AdministrativeDivisionService administrativeDivisionService) {
this.administrativeDivisionService = administrativeDivisionService;
}
} }
@@ -880,8 +880,13 @@ public class PropertyController {
districtInfoDto.setAddressAlias(district.getAddrAlias()); districtInfoDto.setAddressAlias(district.getAddrAlias());
if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null
&& district.getLng2() != 0) { && district.getLng2() != 0) {
districtInfoDto.setLat(district.getLat2() / 10000000000D); districtInfoDto.setLat2(district.getLat2() / 10000000000D);
districtInfoDto.setLng(district.getLng2() / 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()); districtInfoDto.setPropertyType(district.getEstateType2());
if (HouseValidator.validateBuildingType(district.getBuildType())) { if (HouseValidator.validateBuildingType(district.getBuildType())) {
@@ -3508,7 +3513,8 @@ public class PropertyController {
if (model.getHall() != null) { if (model.getHall() != null) {
params.add(new QueryParam("hall", model.getHall())); params.add(new QueryParam("hall", model.getHall()));
} }
params.add(new QueryParam("score", QueryParam.GREATER_THAN_OPERATOR, 200000000000l)); // 18年之后抓住的数据没有score字段
// params.add(new QueryParam("score", QueryParam.GREATER_THAN_OPERATOR, 200000000000l));
List<DealPrice> dealPrices = dealPriceService.findDealPrices(params, max); List<DealPrice> dealPrices = dealPriceService.findDealPrices(params, max);
List<DealPrice> distinctDealPrices = new ArrayList<DealPrice>(); List<DealPrice> distinctDealPrices = new ArrayList<DealPrice>();
for (DealPrice dealPrice : dealPrices) { for (DealPrice dealPrice : dealPrices) {
@@ -542,7 +542,7 @@ public class UserController {
String code = usersInfoService.randomCode(); String code = usersInfoService.randomCode();
System.out.println(code); System.out.println(code);
try { try {
smsService.send(model.getMobile(), "【房价网】你的验证码是" + code + ",请立即验证。"); smsService.send(model.getMobile(), "【百盛评估】你的验证码是" + code + ",请立即验证。");
resultModel.setResult(Message.RESULT_SUCCESS); resultModel.setResult(Message.RESULT_SUCCESS);
CookieUtils.setCookie(mobile + "_" + type, code, "/", 60 * 60 * 24 *7, resp); CookieUtils.setCookie(mobile + "_" + type, code, "/", 60 * 60 * 24 *7, resp);
CacheUtils.putValue(CachePolicyEnum.TINY, FjtUsers.class, mobile, new Date().getTime()); CacheUtils.putValue(CachePolicyEnum.TINY, FjtUsers.class, mobile, new Date().getTime());
@@ -1285,7 +1285,7 @@ public class WeiXinEvaluationController {
Point point = null; Point point = null;
if(district.getLng2()!=null){ if(district.getLng2()!=null){
point = new Point(district.getLng2()/10000000000.0, district.getLat2()/10000000000.0); point = new Point(district.getLng2()/10000000000.0, district.getLat2()/10000000000.0);
}
//boolean flag = InsidePolygon.aboutZone(point, points); //boolean flag = InsidePolygon.aboutZone(point, points);
//boolean flag = InsidePolygon.isPtInPoly(point.getLon(), point.getLat(), points); //boolean flag = InsidePolygon.isPtInPoly(point.getLon(), point.getLat(), points);
boolean flag = InsidePolygon2.checkIsInPolygon(point, points); boolean flag = InsidePolygon2.checkIsInPolygon(point, points);
@@ -1295,6 +1295,8 @@ public class WeiXinEvaluationController {
break; break;
} }
} }
}
Integer yearAge = getBuildYear(district.getFinishBuildingDate()); Integer yearAge = getBuildYear(district.getFinishBuildingDate());
if(pbObj!=null){ if(pbObj!=null){
System.out.println("渤海银行:"+district.getName() +" 年限:"+yearAge+" Level:"+pbObj.getLevel()+" 所属板块:"+pbObj.getName()); System.out.println("渤海银行:"+district.getName() +" 年限:"+yearAge+" Level:"+pbObj.getLevel()+" 所属板块:"+pbObj.getName());
@@ -26,8 +26,14 @@ public class DistrictInfoDto {
private List<String> alias; private List<String> alias;
private List<String> addressAlias; private List<String> addressAlias;
private String videoUrl; private String videoUrl;
//高德坐标
//维度
private Double lat; private Double lat;
//经度
private Double lng; private Double lng;
// 百度坐标
private Double lat2;
private Double lng2;
private String developer; private String developer;
private String buildType; private String buildType;
private String estateCompany; private String estateCompany;
@@ -102,6 +108,21 @@ public class DistrictInfoDto {
private String township; private String township;
private String landProperty; 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() { public String getDistrict() {
return district; return district;
@@ -9,6 +9,7 @@ import org.hibernate.validator.constraints.NotBlank;
public class AddesssMatchModel extends FangjiaApiModel { public class AddesssMatchModel extends FangjiaApiModel {
private String city; private String city;
private String refCity;
@NotBlank @NotBlank
private String address; private String address;
private String suggestDistrict; private String suggestDistrict;
@@ -24,6 +25,14 @@ public class AddesssMatchModel extends FangjiaApiModel {
private String showCode; private String showCode;
public String getRefCity() {
return refCity;
}
public void setRefCity(String refCity) {
this.refCity = refCity;
}
public String getAddress_1() { public String getAddress_1() {
return address_1; return address_1;
} }
@@ -42,6 +42,10 @@ public class AddressModel extends FangjiaApiModel {
//是否使用地图poi数据 //是否使用地图poi数据
private boolean useMap; private boolean useMap;
//涉农到区之后,是否显式后面的字段值
private String showFullValue;
//是否显示涉农测试用字段值
private String showTestValue;
public boolean isContainsLocation() { public boolean isContainsLocation() {
return containsLocation; return containsLocation;
} }
@@ -258,4 +262,20 @@ public class AddressModel extends FangjiaApiModel {
public void setUseMap(boolean useMap) { public void setUseMap(boolean useMap) {
this.useMap = 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);
}
}
}
@@ -110,7 +110,9 @@
</div> </div>
</div> </div>
<div class="content-block"> <div class="content-block">
<p><a href="../weiXinEvaluation/form?id=${id}" class="button button-big button-fill evaluation_btn external">房产评估</a></p> <p>
<a href="../weiXinEvaluation/form?id=${id}" class="button button-big button-fill evaluation_btn external">房产评估</a>
</p>
</div> </div>
</#if> </#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> </head>
<body> <body>
<!-- 替换百盛图片 -->
<div class="page-group"> <div class="page-group">
<div class="page page-current"> <div class="page page-current">
<div class="content login_bg2"> <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/baisheng_logo.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/bs_bananer.jpg" id="bannersDiv" style="width: 100%;height: 220px;"></div>
<div class="login_content" style="margin-top: 8%;"> <div class="login_content" style="margin-top: 8%;">
<div class="login_input" id="bhFrom"> <div class="login_input" id="bhFrom">
<div class="inputInfo01"> <div class="inputInfo01">
+6
View File
@@ -530,6 +530,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.fangjia</groupId>-->
<!-- <artifactId>fangjia-open</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.aliyun</groupId> <groupId>com.aliyun</groupId>
@@ -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)
@@ -0,0 +1,57 @@
import com.fangjia.core.ProvinceData
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import com.lowagie.text.Row
import javafx.scene.control.Cell
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)
//// }
//
//})
//
//import com.fangjia.core.ProvinceData
//
//import com.fangjia.script.util.ExcelUtils
//
//
//String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表.xlsx"
//ExcelUtils.removeEmptyRow(excelFilePath)
//ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
//
// def province1 = items['A']
// def province
//
// 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)
// items['D'] = citys.toString()
//
//})
@@ -5,14 +5,15 @@ import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject import net.sf.json.JSONObject
ExcelUtils.removeEmptyRow("F:\\估家\\文件\\北交所\\testcopy.xlsx") String excelFilePath = "F:\\¹À¼Ò\\Îļþ\\±±½»Ëù\\testcopy1.xlsx";
ExcelUtils.singleThreadingModify("F:\\估家\\文件\\北交所\\testcopy.xlsx", { List items -> ExcelUtils.removeEmptyRow(excelFilePath)
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy.xlsx"; ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
String comprehensiveUrl = "http://192.168.10.15:9180/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://192.168.10.15:9180/addrSvc/avgPrice"; String comprehensiveUrl = "http://localhost:9180/comprehensiveQuery/houseValueInformation";
String valueUrl = "http://192.168.10.15:9180/property/addressEvaluate"; String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
String caseUrl = "http://192.168.10.15:9180/house/case"; String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
String poiUrl = "http://192.168.10.15:9180/district/addrFacilitys"; String caseUrl = "http://open.fangjia.com/house/case";
String poiUrl = "http://open.fangjia.com/district/addrFacilitys";
HttpRequest httpRequest = new HttpRequest(); HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>() map = new HashMap<String, String>()
@@ -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'] = "该地址不支持估价!"
}
}
})
@@ -0,0 +1,4 @@
import org.bson.types.ObjectId
a = new ObjectId()
print(a)
@@ -0,0 +1,350 @@
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import com.fangjia.datastore.driver.DSCollection
import com.fangjia.datastore.driver.DataStore
import com.fangjia.script.BaseBatch
import com.fangjia.script.BatchOwner
import com.fangjia.script.Watcher
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.CommonUtils
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
//@BatchOwner(Watcher.MaJinTao)
class CommunityHouseSampleBatch extends BaseBatch {
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017)
DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017)
DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird")
static void main(String[] args) {
runBatch(new CommunityHouseSampleBatch(), args)
}
def findHouseCase(Object district_stat, Map<String, List> houseMap) {
// 查本小区的房源
def houseQuery = new BasicDBObject()
houseQuery.put("cat", "sell")
houseQuery.put("city", district_stat.city)
houseQuery.put("region", district_stat.region)
houseQuery.put("district_name", district_stat.district_name)
def houseListAll = SEABIRD.find(houseQuery).toList()
// 将均价符合的房源放入结果集
def houseList = houseListAll.findAll() { housecase ->
def totalPrice = housecase.total_price
def houseArea = housecase.area
def houseAvgPrice = totalPrice / houseArea
def avgPrice = district_stat.avg_price
houseAvgPrice >= avgPrice * 0.8 && houseAvgPrice <= avgPrice * 1.2
}
// 将样本数据按面积段分,200以下每10为一段,200以上每30为一段
// 分段的字段规则 area: 23.4 对应[20,30] 标记为 g20
for (def housecase : houseList) {
if (housecase.area <= 200) {
def area = housecase.area.toInteger()
def key = "g" + (area / 10).toInteger() * 10
def gList = houseMap.get(key)
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else if (gList.size() < 10) {
gList.add(housecase)
houseMap.put(key, gList)
}
} else {
def area = housecase.area.toInteger()
def startPoint = 200
def segmentSize = 30
def rangeStart = (startPoint + (Math.floor((area - startPoint) / segmentSize) * segmentSize)).toInteger()
def key = "g" + rangeStart
def gList = houseMap.get(key)
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else if (gList.size() < 10) {
gList.add(housecase)
houseMap.put(key, gList)
}
}
}
}
@Override
void process(Object args) {
ExecutorService executorService = Executors.newFixedThreadPool(5)
try {
def cityList = CommonUtils.findAllCity()
// 测试
cityList = cityList.subList(0, 5)
cityList.each { city ->
executorService.submit({
def count = 0
def documents = []
def weekend = DateUtils.getFirstDayOfWeek(new Date())
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
// 测试
districts = districts.subList(0, 10)
districts.each { district ->
Map<String, List> houseMap = [:]
def district_stat = districtPriceMap.get(district.city + "##" + district.region + "##" + district.name)
if (district_stat != null) {
findHouseCase(district_stat, houseMap)
}
if (houseMap == null || houseMap.size() == 0) {
def aroundDistrictList = DbUtils.findAroundDistrictByRadius(district, 3000)
// def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
aroundDistrictList.each { aroundDistrict ->
def aroundDistrict_stat = districtPriceMap.get(aroundDistrict.city + "##" + aroundDistrict.region + "##" + aroundDistrict.name)
if (aroundDistrict_stat != null) {
findHouseCase(aroundDistrict_stat, houseMap)
}
}
}
def document = new BasicDBObject()
document.put("city", district.city)
document.put("region", district.region)
document.put("district_name", district.name)
document.put("house_case", houseMap)
documents.add(document)
count++
if (count % 10 == 0) {
println(city + "已处理小区数----------------------------------------------------" + count)
}
}
HOUSE_CASE.insert(documents)
} as Runnable)
}
} finally {
executorService.shutdown()
executorService.awaitTermination(Long.MAX_VALUE, java.util.concurrent.TimeUnit.NANOSECONDS)
}
}
}
/*
package com.fangjia.script.sync
import com.fangjia.datastore.driver.DSCollection
import com.fangjia.datastore.driver.DataStore
import com.fangjia.script.BaseBatch
import com.fangjia.script.BatchOwner
import com.fangjia.script.Watcher
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.CommonUtils
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
@BatchOwner(Watcher.MaJinTao)
class CommunityHouseSampleBatch extends BaseBatch {
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017)
DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017)
// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "192.168.0.43", 28017)
DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird")
static void main(String[] args) {
runBatch(new CommunityHouseSampleBatch(), args)
}
def findHouseCase(Object district_stat, Map<String, List> houseMap) {
// 查本小区的房源
def houseQuery = new BasicDBObject()
//houseQuery.put("city", "深圳")
//houseQuery.put("region", "福田")
//houseQuery.put("district_name", "中泰燕南名庭")
houseQuery.put("cat", "sell")
houseQuery.put("city", district_stat.city)
houseQuery.put("region", district_stat.region)
houseQuery.put("district_name", district_stat.district_name)
def houseListAll = SEABIRD.find(houseQuery).toList()
// 将均价符合的房源放入结果集
def houseList = houseListAll.findAll() { housecase ->
def totalPrice = housecase.total_price
def houseArea = housecase.area
def houseAvgPrice = totalPrice / houseArea
def avgPrice = district_stat.avg_price
if (houseAvgPrice >= avgPrice * 0.8 && houseAvgPrice <= avgPrice * 1.2) {
return true
} else {
return false
}
}
// 将样本数据按面积段分,200以下每10为一段,200以上每30为一段
// 分段的字段规则 area: 23.4 对应[20,30] 标记为 g20
for (def housecase : houseList) {
if (housecase.area <= 200) {
def area = housecase.area.toInteger()
def key = "g" + (area / 10).toInteger() * 10
// println(key)
// 获取该面积段的房源列表
def gList = houseMap.get(key)
// 如果为空,说明该面积段没有房源,新建一个list,放入
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else {
// 如果该面积段已经有10个房源,就不再放入
if (gList.size() < 10) {
// 如果不为空,说明该面积段已经有房源,直接放入
gList.add(housecase)
houseMap.put(key, gList)
}
}
} else {
def area = housecase.area.toInteger()
def startPoint = 200
def segmentSize = 30
def rangeStart = (startPoint + (Math.floor((area - startPoint) / segmentSize) * segmentSize)).toInteger()
def key = "g" + rangeStart
// println(key)
// 获取该面积段的房源列表
def gList = houseMap.get(key)
// 如果为空,说明该面积段没有房源,新建一个list,放入
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else {
// 如果该面积段已经有10个房源,就不再放入
if (gList.size() < 10) {
gList.add(housecase)
houseMap.put(key, gList)
}
}
}
}
}
@Override
void process(Object args) {
def count = 0
def cityList = CommonUtils.findAllCity()
// 测试用,先只取一条
// cityList = cityList.subList(0, 1)
print(cityList.size())
print(cityList.toString())
// cityList.each { city ->
def city = cityList.get(0)
print(city)
def documents = []
//查询该城市的所有小区
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
//测试用,先只取5个小区
// districts = districts.subList(0, 2)
// 查询所有的小区均价
def weekend = DateUtils.getFirstDayOfWeek(new Date());
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
for (def district : districts) {
Map<String, List> houseMap = [:]
def district_stat = districtPriceMap.get(district.city + "##" + district.region + "##" + district.name)
// 拿到小区对应的均价之后,去查房源
if (district_stat != null) {
findHouseCase(district_stat, houseMap)
}
// 没有拿到小区对应的均价,找小区周边的三十个小区
def aroundDistrictListAll = DbUtils.findAroundDistrictByRadius(district, 3000)
def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
// 遍历周边小区,找到均价符合的房源
aroundDistrictList.each { aroundDistrict ->
def aroundDistrict_stat = districtPriceMap.get(aroundDistrict.city + "##" + aroundDistrict.region + "##" + aroundDistrict.name)
// 拿到小区对应的均价之后,去查房源
if (aroundDistrict_stat != null) {
findHouseCase(aroundDistrict_stat, houseMap)
}
}
print(houseMap)
// 创建一个新的文档
def document = new BasicDBObject()
// 将 houseMap 和 communityStr 放入文档
document.put("city", district.city)
document.put("region", district.region)
document.put("district_name", district.name)
document.put("house_case", houseMap)
// 将文档插入到 MongoDB 中
// HOUSE_CASE.in(document)
documents.add(document)
count++
if (count % 10 == 0) {
print("已处理小区数----------------------------------------------------" + count)
}
}
HOUSE_CASE.insert(documents)
}
// }
}
*/
@@ -454,7 +454,7 @@ public class ExcelUtils{
def data = ExcelUtils.read(fileName, srcSheetIndex, 0) def data = ExcelUtils.read(fileName, srcSheetIndex, 0)
def body = data.subList(1, data.size()) def body = data.subList(1, data.size())
def nThread = Runtime.getRuntime().availableProcessors() * 3 def nThread = 10
println nThread println nThread
ExecutorService executorService = Executors.newFixedThreadPool(3) ExecutorService executorService = Executors.newFixedThreadPool(3)
final AtomicInteger counter = new AtomicInteger(0) final AtomicInteger counter = new AtomicInteger(0)
@@ -299,6 +299,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
selectedSample.add(querySamples.get(i)); selectedSample.add(querySamples.get(i));
} }
fillOthersInfo(selectedSample); fillOthersInfo(selectedSample);
// 将最终样本进行排序
sortForSample(selectedSample, target);
List<Sample> sampleList = new ArrayList<Sample>(selectedSample.size()); List<Sample> sampleList = new ArrayList<Sample>(selectedSample.size());
for (SampleWrapper sampleWrapper : selectedSample) { for (SampleWrapper sampleWrapper : selectedSample) {
@@ -515,12 +517,12 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
} }
//½«Êý¾Ý·ÅÈëÑù±¾²Ö¿â //½«Êý¾Ý·ÅÈëÑù±¾²Ö¿â
for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) { for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) {
//超过两个,只取两个 //每个小区取5个样本
// 取三个
if (entry.getValue().size()>=3){ if (entry.getValue().size()>=5){
querySamples.addAll(entry.getValue().subList(0,2)); querySamples.addAll(entry.getValue().subList(0,5));
}else { }else {
// 不超过两个,全部放入 // 不超过五个,全部放入
querySamples.addAll(entry.getValue()); querySamples.addAll(entry.getValue());
} }
} }
@@ -2747,11 +2747,14 @@ public class DistrictServiceImpl implements DistrictService {
public Integer getCreateYear(District district) { public Integer getCreateYear(District district) {
Integer buildYear = getYearFormDate(district.getCreateYear()); Integer buildYear = getYearFormDate(district.getCreateYear());
int minYear = Integer.MAX_VALUE; // int minYear = Integer.MAX_VALUE;
if (buildYear != null && buildYear < minYear) { if (buildYear != null && buildYear < Integer.MAX_VALUE) {
minYear = buildYear; // minYear = buildYear;
return buildYear;
}else {
return null;
} }
return minYear; // return minYear;
} }
public Integer getBuildYear(District district) { 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 * @return
*/ */
User findUserById(Long id); User findUserById(Long id);
void clearApiUserAuthorityCache(long userId);
} }
View File