Merge branch 'open_gj' into 'master'

优化报告加载速率

See merge request !87
This commit is contained in:
2021-08-20 16:59:22 +08:00
19 changed files with 404 additions and 44 deletions
@@ -4960,7 +4960,7 @@ public class PropertyController {
}
/***
* 小区租金估值报告
* 小区租金估值报告(上半部分)
* @param model
* @param request
* @return
@@ -5060,6 +5060,153 @@ public class PropertyController {
Integer startPrice = (int)(evaluation.getTotalPrice() - evaluation.getTotalPrice()*0.2);
Integer endPrice = (int)(evaluation.getTotalPrice() + evaluation.getTotalPrice()*0.2);
//周边相似小区
// if (null == model.getRadius()) {// 设置默认值
// model.setRadius(1000);
// }
// String[] fields = { "city", "region", "name", "estateType2", "id","finishBuildingDate"};
// List<District> allDistricts = districtService.findNearestDistrict(district, model.getRadius(), fields, Integer.MAX_VALUE);
// //按条件过滤相似小区
// Integer buildYear = null;
// List<District> districts = new ArrayList<District>();
// if(StringUtils.isNotBlank(district.getFinishBuildingDate())){
// buildYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate());
// if(buildYear!=null){
// districts = new ArrayList<District>();
// int startYear = buildYear -7;
// int endYear = buildYear + 7;
// for(District dist : allDistricts){
// if(StringUtils.isNotBlank(dist.getFinishBuildingDate())){
// int simlarDistYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate());
// if(simlarDistYear>=startYear && simlarDistYear<=endYear && StringUtils.isNotBlank(district.getEstateType2()) && StringUtils.isNotBlank(dist.getEstateType2()) && district.getEstateType2().equals(dist.getEstateType2())){
// districts.add(dist);
// }
// }
// }
// }
// }
//相似房源
// Double startArea = model.getSize() - model.getSize()*0.1;
// Double endArea = model.getSize() + model.getSize()*0.1;
// Integer startDate = Integer.parseInt(org.apache.tools.ant.util.DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
// List<Seawater> houses = seawaterService.findSeawatersFromEs2("rent", district.getCity(), district.getRegion(), district.getName(), null, null, startDate, null,
// startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc");
// //无评估小区房源用周边相似小区的房源
// if(null == houses || houses.size()==0){
// for (District dist : districts) {
// houses = seawaterService.findSeawatersFromEs2("rent", dist.getCity(), dist.getRegion(), dist.getName(), null, null, startDate, null,
// startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc");
// if(houses!=null && houses.size()>0){
// break;
// }
// }
// }
// districtPriceMap.put("houses", houses);
// //周边相似小区租金
// Integer room = null;
// if(model.getRoom()!=0){
// room = model.getRoom();
// }else{
// room = houseService.getDistrictRoomType((float)model.getSize());
// }
// if (null != districts) {
// if (null != room) {
// List<DistrictHouseDtao> dtos = new ArrayList<DistrictHouseDtao>();
// Date weekend = DateUtil.getFirstDayOfWeek(new Date());
// for (District dist : districts) {
//
// List<DistrictRoomSqmetreRent> districtRoomSqmetreRents = districtRoomSqmetreRentService.findDistrictRoomSqmetreRents(dist, 1, room);
//
// ///List<DistrictStatRent> districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room);
// if (null != districtRoomSqmetreRents && districtRoomSqmetreRents.size() > 0) {
// DistrictRoomSqmetreRent districtRoomSqmetreRent = districtRoomSqmetreRents.get(0);
// if (districtRoomSqmetreRent.getAvgPrice() > 0) {
//
// int startSqPrice = (int)(evaluation.getAvgPrice() - evaluation.getAvgPrice()*0.1);
// int endSqPrice = (int)(evaluation.getAvgPrice() + evaluation.getAvgPrice()*0.1);
//// SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(dist.getCity(), dist.getRegion(), dist.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
// if(districtRoomSqmetreRent.getAvgPrice()>=startSqPrice && districtRoomSqmetreRent.getAvgPrice()<=endSqPrice){
// DistrictHouseDtao dto = new DistrictHouseDtao();
// dto.setCity(dist.getCity());
// dto.setRegion(dist.getRegion());
// dto.setDistrictName(dist.getName());
// dto.setSqAvgPrice(districtRoomSqmetreRent.getAvgPrice());
// dto.setRoom(room);
// dtos.add(dto);
// if(dtos.size()>=5){
// break;
// }
// }
// }
// }
// }
// districtPriceMap.put("districts", dtos);
// }
// }
//
//
// //近一年户型租金走势
// Map<String, Object> trendsMap = districtRoomSqmetreRentService.getRentTrends(district.getCity(), district.getRegion(), district.getName(), room, -12);
//// Map<String, Object> trendsMap = districtStatRentService.getRentTrend(district.getCity(), district.getRegion(), district.getDistrictName(), -12);
// if (MapUtils.isNotEmpty(trendsMap)) {
// Map distMap = (Map) trendsMap.get("distMap");
// Map<String, Integer> trendMap = (Map) distMap.get(String.valueOf(trendsMap.get("room")));
// if (MapUtils.isNotEmpty(trendMap)) {
// for (String key : trendMap.keySet()) {
// Double totalPrice = (trendMap.get(key) * evaluation.getArea());
// trendMap.put(key, totalPrice.intValue());
// }
// }
// }
// districtPriceMap.put("trends", trendsMap);
//
//
// //成交的租房房源
// List<RentDealPrice> rentTrades = rentDealPriceService.getRentDealPrices(district.getCity(), district.getRegion(), district.getName(), 5);
// districtPriceMap.put("trades", rentTrades);
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
return mav;
} else {
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav;
}
}
/***
* 小区租金估值报告(下半部分)
* @param model
* @param request
* @return
* @throws NumberFormatException
* @throws IllegalAccessException
*/
@Authority(role = Role.NONE)
public Object rentReport2Action(PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException {
RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest");
/* 先到CPDB库中查找小区 */
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district");
model.setRegion(district.getRegion());
model.setDistrictName(district.getName());
if (StringUtils.isBlank(model.getPropertyType())) {
if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) {
model.setPropertyType("1");
}
}
Evaluation evaluation = buildEvaluation(model, request);
evaluation.setSource("api_property_evaluate_rent");
evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate());
if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) {
evaluation.setAvgPrice((int)(evaluation.getTotalPrice()/evaluation.getArea()));
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
Integer startPrice = (int)(evaluation.getTotalPrice() - evaluation.getTotalPrice()*0.2);
Integer endPrice = (int)(evaluation.getTotalPrice() + evaluation.getTotalPrice()*0.2);
//周边相似小区
if (null == model.getRadius()) {// 设置默认值
model.setRadius(1000);
@@ -5170,7 +5317,6 @@ public class PropertyController {
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
return mav;
} else {
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav;
}
@@ -8,6 +8,7 @@ import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import com.fangjia.open.util.InsidePolygon2;
import com.fangjia.service.mongo.fangjia.PriceBorderService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -808,10 +809,13 @@ public class WeiXinEvaluationController {
Point point = new Point(Double.valueOf(ll[0]), Double.valueOf(ll[1]));
points.add(point);
}
Point point = new Point(district.getLng2()/10000000000.0, district.getLat2()/10000000000.0);
boolean flag = InsidePolygon.aboutZone(point, points);
Point point = new Point(district.getLng()/10000000000.0, district.getLat()/10000000000.0);
//boolean flag = InsidePolygon.aboutZone(point, points);
//boolean flag = InsidePolygon.isPtInPoly(point.getLon(), point.getLat(), points);
boolean flag = InsidePolygon2.checkIsInPolygon(point, points);
if(flag){
pbObj = pb;
System.out.println(district.getRegion()+" "+district.getName()+" "+pb.getName());
break;
}
}
@@ -143,5 +143,44 @@ public class InsidePolygon {
if ( ( (odd >> 1) << 1) == odd)
return false;
return true;
}
}
public static boolean isPtInPoly (double ALon , double ALat , List<Point> ps) {
int iSum, iCount, iIndex;
double dLon1 = 0, dLon2 = 0, dLat1 = 0, dLat2 = 0, dLon;
if (ps.size() < 3) {
return false;
}
iSum = 0;
iCount = ps.size();
for (iIndex = 0; iIndex<iCount;iIndex++) {
if (iIndex == iCount - 1) {
dLon1 = ps.get(iIndex).getLon();
dLat1 = ps.get(iIndex).getLat();
dLon2 = ps.get(0).getLon();
dLat2 = ps.get(0).getLat();
} else {
dLon1 = ps.get(iIndex).getLon();
dLat1 = ps.get(iIndex).getLat();
dLon2 = ps.get(iIndex + 1).getLon();
dLat2 = ps.get(iIndex + 1).getLat();
}
// 以下语句判断A点是否在边的两端点的水平平行线之间,在则可能有交点,开始判断交点是否在左射线上
if (((ALat >= dLat1) && (ALat < dLat2)) || ((ALat >= dLat2) && (ALat < dLat1))) {
if (Math.abs(dLat1 - dLat2) > 0) {
//得到 A点向左射线与边的交点的x坐标:
dLon = dLon1 - ((dLon1 - dLon2) * (dLat1 - ALat) ) / (dLat1 - dLat2);
// 如果交点在A点左侧(说明是做射线与 边的交点),则射线与边的全部交点数加一:
if (dLon < ALon) {
iSum++;
}
}
}
}
if ((iSum % 2) != 0) {
return true;
}
return false;
}
}
@@ -0,0 +1,116 @@
package com.fangjia.open.util;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
public class InsidePolygon2 {
/**
* 判断当前位置是否在多边形区域内
*
* @param checkPoint 当前经纬度
* @param areaAround 围栏范围
* @return
*/
public static boolean checkIsInPolygon(Point checkPoint, List<Point> areaAround) {
Point2D.Double point = new Point2D.Double(checkPoint.getLat(), checkPoint.getLon());
List<Point2D.Double> pointList = new ArrayList<Point2D.Double>();
for (Point everyPoint : areaAround) {
Point2D.Double polygonPoint = new Point2D.Double(everyPoint.getLat(), everyPoint.getLon());
pointList.add(polygonPoint);
}
return checkIsPtInPoly(point, pointList);
}
/**
* 判断点是否在多边形内,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true
*
* @param point 检测点
* @param pts 多边形的顶点
* @return 点在多边形内返回true, 否则返回false
*/
public static boolean checkIsPtInPoly(Point2D.Double point, List<Point2D.Double> pts) {
int N = pts.size();
//如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true
boolean boundOrVertex = true;
//cross points count of x
int intersectCount = 0;
//浮点类型计算时候与0比较时候的容差
double precision = 2e-10;
//neighbour bound vertices
Point2D.Double p1, p2;
//当前点
Point2D.Double p = point;
//left vertex
p1 = pts.get(0);
//check all rays
for (int i = 1; i <= N; ++i) {
if (p.equals(p1)) {
//p is an vertex
return boundOrVertex;
}
//right vertex
p2 = pts.get(i % N);
//ray is outside of our interests
if (p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)) {
p1 = p2;
//next ray left point
continue;
}
//ray is crossing over by the algorithm (common part of)
if (p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)) {
//x is before of ray
if (p.y <= Math.max(p1.y, p2.y)) {
//overlies on a horizontal ray
if (p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)) {
return boundOrVertex;
}
//ray is vertical
if (p1.y == p2.y) {
//overlies on a vertical ray
if (p1.y == p.y) {
return boundOrVertex;
//before ray
} else {
++intersectCount;
}
} else {
//cross point on the left side
//cross point of y
double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y;
//overlies on a ray
if (Math.abs(p.y - xinters) < precision) {
return boundOrVertex;
}
//before ray
if (p.y < xinters) {
++intersectCount;
}
}
}
} else {
//special case when ray is crossing through the vertex
//p crossing over p2
if (p.x == p2.x && p.y <= p2.y) {
//next vertex
Point2D.Double p3 = pts.get((i + 1) % N);
//p.x lies between p1.x & p3.x
if (p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)) {
++intersectCount;
} else {
intersectCount += 2;
}
}
}
//next ray left point
p1 = p2;
}
//偶数在多边形外
if (intersectCount % 2 == 0) {
return false;
} else {
//奇数在多边形内
return true;
}
}
}
@@ -201,6 +201,7 @@
<script type="text/javascript">
let chart;
$("#download").bind('click', function(){
$.toast("报告下载中,请耐心等待");
$("#download").css('color', 'blue')
let chartImgUrl = $('#chartImgUrl').val();
window.location.href = "download?city="+params.city+"&district="+params.district+"&name="+params.name+"&address="+params.address+"&size="+params.size+"&floor="+params.floor
@@ -252,8 +253,25 @@
$('span[name="size"]').text(result.size)
$('span[name="height"]').text(result.height)
$('span[name="fitment"]').text(result.fitment)
}else{
$.toast(data.msg);
}
},
error: function () {
// 历史租金
}
})
$.ajax({
// 注意需要加..
url: '../property/rentReport2',
data: params,
dataType: "json",
type: "post",
success: function (data) {
if (data.code == 200) {
let result = data.result;
//历史租金
var charts = {}
// charts.series = [{
// name: '1居室',
@@ -280,7 +298,7 @@
createChartNow('districtRentTrendsChart', charts, true);
}
// 已租房源
//已租房源
var trades = result.trades;
if (trades && trades.length > 0) {
$('#trades').empty();
@@ -288,16 +306,16 @@
var fitment = d.fitment != undefined ? d.fitment : '';
var hall = d.hall != undefined ? d.hall : '';
$('#trades').append('<tr class="bg"> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + (d.totalPrice != undefined ? d.totalPrice : '') + '</td> \
<td>' + (d.area != undefined ? d.area : '') + '</td> \
<td>' + (d.room != undefined ? d.room : '') + '</td> \
<td>' + hall + '</td> \
<td>' + fitment + '</td> \
<td>' + formatDate(d.tradeDate) + '</td> \
</tr>');
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + (d.totalPrice != undefined ? d.totalPrice : '') + '</td> \
<td>' + (d.area != undefined ? d.area : '') + '</td> \
<td>' + (d.room != undefined ? d.room : '') + '</td> \
<td>' + hall + '</td> \
<td>' + fitment + '</td> \
<td>' + formatDate(d.tradeDate) + '</td> \
</tr>');
})
}
@@ -309,16 +327,16 @@
var fitment = d.fitment != undefined ? d.fitment : '';
var date = (d.pDate + '').substring(0, 4) + "-" + (d.pDate + '').substring(4, 6) + "-" + (d.pDate + '').substring(6, 8)
$('#referenceHouses').append('<tr class="bg"> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + (d.totalPrice != undefined ? d.totalPrice : '') + '</td> \
<td>' + (d.area != undefined ? d.area : '') + '</td> \
<td>' + (d.room != undefined ? d.room : '') + '</td> \
<td>' + (d.hall != undefined ? d.hall : '')+ '</td> \
<td>' + fitment + '</td> \
<td>' + date + '</td> \
</tr>');
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + d.districtName + '</td> \
<td>' + (d.totalPrice != undefined ? d.totalPrice : '') + '</td> \
<td>' + (d.area != undefined ? d.area : '') + '</td> \
<td>' + (d.room != undefined ? d.room : '') + '</td> \
<td>' + (d.hall != undefined ? d.hall : '')+ '</td> \
<td>' + fitment + '</td> \
<td>' + date + '</td> \
</tr>');
})
}
@@ -329,23 +347,18 @@
$('#sameDistricts').empty()
sameDistricts.forEach(function(d){
$('#sameDistricts').append('<tr class="bg"> \
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + (d.districtName != undefined ? d.districtName:'' ) + '</td> \
<td>' + (d.sqAvgPrice != undefined ? d.sqAvgPrice:'') + '</td> \
<td>' + (d.room != undefined ? d.room:'') + '</td> \
<td>1</td> \
</tr>');
<td class="td01">' + d.city + '</td> \
<td class="td02">' + d.region + '</td> \
<td>' + (d.districtName != undefined ? d.districtName:'' ) + '</td> \
<td>' + (d.sqAvgPrice != undefined ? d.sqAvgPrice:'') + '</td> \
<td>' + (d.room != undefined ? d.room:'') + '</td> \
<td>1</td> \
</tr>');
})
}
}else{
$.toast(data.msg);
}
},
error: function () {
}
})
});
};
var formatDate = function (dateStr) {
var date = new Date(dateStr);
@@ -260,6 +260,25 @@
return
}
$("#evaluateBtn").prop("disabled", true)
// 用户输入可能为地址,需要匹配,在估价
// let city = $('input[name="city"]').val()
// let address = $('input[name="address"]').val()
//
// $.ajax({
// // 注意需要加..
// url: '../address/match',
// data: {'city': city, 'address': address},
// dataType: "json",
// type: "post",
// success: function (data) {
// debugger
// if (data.code == 200) {
//
// }
// }
// })
$.ajax({
// 注意需要加..
url: '../ccbRent/evaluateRent',
Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 69 KiB

@@ -21,8 +21,9 @@
<div class="page-group">
<div class="page page-current">
<div class="content login_bg">
<div class="login_logo"><img src="../static/images/bohaiyidai2.jpg"></div>
<div class="content login_bg" style="background: url(../static/images/bhbm.png);">
<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/bohaiyidai2.jpg" style="width: 80%;height: 100px;margin: 20px auto;"></div>
<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/bh1.png" id="bannersDiv" style="width: 100%;height: 150px;"></div>
<div class="login_content">
<div class="login_input">
<div class="inputInfo01">
@@ -40,9 +41,10 @@
</div>
<p>忘记密码请拨打客服电话<a href="tel:4001883787">400-888-8811</a>进行查询</p>
<div class="content-block">
<p><a href="#" class="button button-big login_btn">登录</a></p>
<p><a href="#" class="button button-big login_btn" style="background: #045FB4;">登录</a></p>
</div>
</div>
<!--<div class="login_logo" style="margin-top: 0px;"><img src="../static/images/bhbm.png" style="width: 80%;height: 150px;"></div>-->
</div>
</div>
</div>
@@ -51,7 +53,28 @@
<script type='text/javascript' src='https://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<script type='text/javascript' charset='utf-8'>
$(function() {
var counter = 0
var images = ["bh1.png","bh2.png", "bh3.png"]
function run(){
console.log("coming")
setInterval(changeImg, 5000)
}
function changeImg(){
counter++
if(counter==images.length)
counter=0
var imgUrl = "../static/images/"+images[counter]
console.log(imgUrl)
$("#bannersDiv").attr("src",imgUrl)
}
run();
var checkUsername = function(username) {
if(username == "") {
$.toast("用户名不能为空");