Merge branch 'master' of http://gitlab.fangjia.com/dev0/main
This commit is contained in:
@@ -159,6 +159,11 @@
|
||||
<artifactId>jfreechart</artifactId>
|
||||
<version>1.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlgraphics</groupId>
|
||||
<artifactId>batik-codec</artifactId>
|
||||
<version>1.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.sothis</groupId>
|
||||
<artifactId>sothis-core</artifactId>
|
||||
|
||||
+46
-8
@@ -26,11 +26,18 @@ import com.fangjia.service.mongo.fangjia.FileService;
|
||||
import com.fangjia.service.mongo.fangjia.SeawaterService;
|
||||
import com.fangjia.service.util.DistrictScoreUtil;
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import org.apache.batik.transcoder.Transcoder;
|
||||
import org.apache.batik.transcoder.TranscoderException;
|
||||
import org.apache.batik.transcoder.TranscoderInput;
|
||||
import org.apache.batik.transcoder.TranscoderOutput;
|
||||
import org.apache.batik.transcoder.image.JPEGTranscoder;
|
||||
import org.apache.batik.transcoder.image.PNGTranscoder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.sothis.core.util.CollectionUtils;
|
||||
@@ -39,11 +46,10 @@ import org.sothis.web.mvc.annotation.Param;
|
||||
import org.xhtmlrenderer.pdf.ITextFontResolver;
|
||||
import org.xhtmlrenderer.pdf.ITextRenderer;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -84,7 +90,7 @@ public class CcbRentController {
|
||||
public Object downloadPageAction(PropertyEvaluationModel result, HttpServletRequest request, @Param(name = "city") String city, @Param(name = "district") String districtStr,
|
||||
@Param(name = "name") String name, @Param(name = "address") String address,
|
||||
@Param(name = "size") Double size, @Param(name = "floor") Integer floor, @Param(name = "height") Integer height, @Param(name = "room") Integer room,
|
||||
@Param(name = "hall") Integer hall, @Param(name = "toilet") Integer toilet, @Param(name = "direction") String direction, @Param(name = "fitment") String fitment) {
|
||||
@Param(name = "hall") Integer hall, @Param(name = "toilet") Integer toilet, @Param(name = "direction") String direction, @Param(name = "fitment") String fitment, @Param(name = "chartImgUrl") String chartImgUrl) {
|
||||
com.fangjia.open.model.PropertyEvaluationModel model = new com.fangjia.open.model.PropertyEvaluationModel();
|
||||
model.setCity(city);
|
||||
model.setDistrict(districtStr);
|
||||
@@ -261,7 +267,8 @@ public class CcbRentController {
|
||||
districtPriceMap.put("trends", trendsMap);
|
||||
|
||||
// 生成走势图图片,一遍转pdf
|
||||
String tradesImgUrl = buildTrendImage(trendsMap, room);
|
||||
//String tradesImgUrl = buildTrendImage(trendsMap, room);
|
||||
String tradesImgUrl = chartImgUrl;
|
||||
|
||||
//成交的租房房源
|
||||
List<RentDealPrice> rentTrades = rentDealPriceService.getRentDealPrices(district.getCity(), district.getRegion(), district.getName(), 5);
|
||||
@@ -426,23 +433,54 @@ public class CcbRentController {
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
public Object saveHighChartAsImageAction(HttpServletRequest request, HttpServletResponse response) {
|
||||
String svg = request.getParameter("svg");
|
||||
ByteArrayOutputStream out = null;
|
||||
String url = null;
|
||||
try {
|
||||
svg = svg.replaceAll(":rect", "rect");
|
||||
Transcoder t = new PNGTranscoder();
|
||||
out = new ByteArrayOutputStream();
|
||||
TranscoderInput input = new TranscoderInput(new StringReader(svg));
|
||||
TranscoderOutput output = new TranscoderOutput(out);
|
||||
t.transcode(input, output);
|
||||
byte[] data = out.toByteArray();
|
||||
String id = new ObjectId().toString();
|
||||
fileService.save(id,"o", data, "image/png", "o");
|
||||
url = "http://img0.fangjia.com/stc/fs/" + DataUtil.encodePicUrl(id, "o", "house");
|
||||
} catch (TranscoderException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
JsonModel model = new JsonModel();
|
||||
AutoCompleteBo bo = new AutoCompleteBo();
|
||||
bo.setAddress(url);
|
||||
model.setJsonModel(bo);
|
||||
return model;
|
||||
}
|
||||
|
||||
public void downloadAction(HttpServletResponse response, HttpServletRequest request, @Param(name = "city") String city, @Param(name = "district") String district,
|
||||
@Param(name = "name") String name, @Param(name = "address") String address,
|
||||
@Param(name = "size") Double size, @Param(name = "floor") Integer floor, @Param(name = "height") Integer height, @Param(name = "room") Integer room,
|
||||
@Param(name = "hall") Integer hall, @Param(name = "toilet") Integer toilet, @Param(name = "direction") String direction, @Param(name = "fitment") String fitment) throws IOException {
|
||||
@Param(name = "hall") Integer hall, @Param(name = "toilet") Integer toilet, @Param(name = "direction") String direction, @Param(name = "fitment") String fitment, @Param(name = "chartImgUrl") String chartImgUrl) throws IOException {
|
||||
response.setHeader("Content-disposition", "attachment; filename=report.pdf");
|
||||
response.setContentType("application/pdf;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = response.getOutputStream();
|
||||
ITextRenderer renderer = new ITextRenderer(35, 20);
|
||||
ITextRenderer renderer = new ITextRenderer(35, 24);
|
||||
ITextFontResolver fontResolver = renderer.getFontResolver();
|
||||
String fontUrl = ActionContext.getContext().getServletContext().getRealPath("/") + "fonts" + File.separator + "simsun.ttc";
|
||||
fontResolver.addFont(fontUrl, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
|
||||
final String path = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
String url = path + "/ccbRent/downloadPage?city=" + DataUtil.urlEncode(city) + "&district="+DataUtil.urlEncode(district)+"&name="+DataUtil.urlEncode(name);
|
||||
url += "&address=" + DataUtil.urlEncode(address) +"&size="+size+"&floor="+floor+"&height="+height+"&room="+room+"&hall="+hall+"&toilet="+toilet+"&direction="+direction+"&fitment="+fitment;
|
||||
url += "&address=" + DataUtil.urlEncode(address) +"&size="+size+"&floor="+floor+"&height="+height+"&room="+room+"&hall="+hall+"&toilet="+toilet+"&direction="+direction+"&fitment="+fitment+"&chartImgUrl="+chartImgUrl;
|
||||
renderer.setDocument(url);
|
||||
renderer.layout();
|
||||
renderer.createPDF(os, true);
|
||||
|
||||
@@ -2,23 +2,24 @@ package com.fangjia.open.util;
|
||||
|
||||
import com.fangjia.core.util.DataUtil;
|
||||
import com.fangjia.service.mongo.fangjia.FileService;
|
||||
import org.apache.batik.transcoder.Transcoder;
|
||||
import org.apache.batik.transcoder.TranscoderException;
|
||||
import org.apache.batik.transcoder.TranscoderInput;
|
||||
import org.apache.batik.transcoder.TranscoderOutput;
|
||||
import org.apache.batik.transcoder.image.JPEGTranscoder;
|
||||
import org.apache.batik.transcoder.image.PNGTranscoder;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.jfree.chart.ChartFactory;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.ChartUtilities;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.NumberAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
|
||||
import org.jfree.chart.ui.ApplicationFrame;
|
||||
import org.jfree.data.category.DefaultCategoryDataset;
|
||||
import org.jfree.ui.RefineryUtilities;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -99,6 +100,42 @@ public class LineChartsUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void svg2ImgTest() {
|
||||
String svg = "<svg height=\"200\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"10,10 75,150 150,60\" style=\"fill:#63BCF7;stroke:black;stroke-width:3\"/></svg>";
|
||||
String type="image/png";
|
||||
String filename="svg";
|
||||
if (null != type && null != svg) {
|
||||
svg = svg.replaceAll(":rect", "rect");
|
||||
String ext = "";
|
||||
Transcoder t = null;
|
||||
if (type.equals("image/png")) {
|
||||
ext = "png";
|
||||
t = new PNGTranscoder();
|
||||
}
|
||||
else if (type.equals("image/jpeg")) {
|
||||
ext = "jpg";
|
||||
t = new JPEGTranscoder();
|
||||
}
|
||||
if (null != t) {
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream("D:\\"+filename+"."+ext);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TranscoderInput input = new TranscoderInput(new StringReader(svg));
|
||||
TranscoderOutput output = new TranscoderOutput(out);
|
||||
try{
|
||||
t.transcode(input, output);
|
||||
System.out.println("out");
|
||||
}
|
||||
catch (TranscoderException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义图表对象
|
||||
* @param rowKey 曲线名,如一居室
|
||||
|
||||
@@ -18,22 +18,24 @@
|
||||
body {
|
||||
overflow: hidden;
|
||||
overflow-y: scroll;
|
||||
background: #f8f8f8;
|
||||
background: white;
|
||||
}
|
||||
.main {
|
||||
margin: 4px 8px 4px 8px;
|
||||
background: #f8f8f8;
|
||||
background: white;
|
||||
}
|
||||
.title {
|
||||
position: relative;
|
||||
color: #1E90FF;
|
||||
}
|
||||
.title1 {
|
||||
font-size: 14px;
|
||||
font-size: 15px;
|
||||
color: #1E90FF;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.p {
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
@@ -105,6 +107,7 @@
|
||||
<div>
|
||||
<div class="title1">5 历史租金</div>
|
||||
<div class="charts" id="districtRentTrendsChart"></div>
|
||||
<input type="hidden" id="chartImgUrl"/>
|
||||
</div>
|
||||
<div>
|
||||
<div class="title1">6 已租房源</div>
|
||||
@@ -179,7 +182,8 @@
|
||||
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
|
||||
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
|
||||
<!-- 暂时注释 -->
|
||||
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
|
||||
<script type="text/javascript" src="http://cdn.highcharts.com.cn/highcharts/9.0.1/highcharts.js"></script>
|
||||
<script type="text/javascript" src="https://code.highcharts.com.cn/highcharts/modules/exporting.js"></script>
|
||||
<script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script>
|
||||
<script type="text/javascript" src="../static/js/trend-charts.js"></script>
|
||||
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
|
||||
@@ -218,9 +222,11 @@
|
||||
// jspdf.addFont('SourceHanSans-Normal.ttf', 'SourceHanSans-Normal', 'normal');
|
||||
// jspdf.setFont('SourceHanSans-Light');
|
||||
//console.log(jspdf.getFontList());
|
||||
var chart;
|
||||
$("#download").bind('click', function(){
|
||||
var 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
|
||||
+"&height="+params.height+"&room="+params.room+"&hall="+params.hall+"&toilet="+params.toilet+"&direction="+params.direction+"&fitment="+params.fitment;
|
||||
+"&height="+params.height+"&room="+params.room+"&hall="+params.hall+"&toilet="+params.toilet+"&direction="+params.direction+"&fitment="+params.fitment+"&chartImgUrl=" + chartImgUrl;
|
||||
// jspdf.html(document.body, {
|
||||
// callback: function (doc) {
|
||||
// doc.save("租金报告.pdf");
|
||||
@@ -319,9 +325,9 @@
|
||||
<td class="td01">' + d.city + '</td> \
|
||||
<td class="td02">' + d.region + '</td> \
|
||||
<td>' + d.districtName + '</td> \
|
||||
<td>' + d.totalPrice + '</td> \
|
||||
<td>' + d.area + '</td> \
|
||||
<td>' + d.room + '</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> \
|
||||
@@ -340,10 +346,10 @@
|
||||
<td class="td01">' + d.city + '</td> \
|
||||
<td class="td02">' + d.region + '</td> \
|
||||
<td>' + d.districtName + '</td> \
|
||||
<td>' + d.totalPrice + '</td> \
|
||||
<td>' + d.area + '</td> \
|
||||
<td>' + d.room + '</td> \
|
||||
<td>' + d.hall + '</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>');
|
||||
@@ -359,9 +365,9 @@
|
||||
$('#sameDistricts').append('<tr class=""> \
|
||||
<td class="td01">' + d.city + '</td> \
|
||||
<td class="td02">' + d.region + '</td> \
|
||||
<td>' + d.districtName + '</td> \
|
||||
<td>' + d.roomPrice + '</td> \
|
||||
<td>' + d.room + '</td> \
|
||||
<td>' + (d.districtName != undefined ? d.districtName:'' ) + '</td> \
|
||||
<td>' + (d.roomPrice != undefined ? d.roomPrice:'') + '</td> \
|
||||
<td>' + (d.room != undefined ? d.room:'') + '</td> \
|
||||
<td>1</td> \
|
||||
</tr>');
|
||||
})
|
||||
@@ -426,8 +432,9 @@
|
||||
var config = {yaxis : yaxis};
|
||||
createHighChartNow(renderId, data, config);
|
||||
};
|
||||
|
||||
function createHighChartNow(renderId, data, config) {
|
||||
var chart = new Highcharts.Chart({
|
||||
chart = new Highcharts.Chart({
|
||||
credits:{
|
||||
enabled:true,
|
||||
text: '',
|
||||
@@ -446,6 +453,9 @@
|
||||
renderTo: renderId,
|
||||
type: 'spline'
|
||||
},
|
||||
exporting: {
|
||||
enabled: false
|
||||
},
|
||||
title: {
|
||||
text: data.title,
|
||||
floating: false,
|
||||
@@ -479,7 +489,26 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
saveHighChartImg();
|
||||
};
|
||||
|
||||
function saveHighChartImg() {
|
||||
var svg = chart.getSVG();
|
||||
$.ajax({
|
||||
// 注意需要加..
|
||||
url: "saveHighChartAsImage",
|
||||
data: {
|
||||
svg:svg
|
||||
},
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function (ret) {
|
||||
if (ret.address != null) {
|
||||
$('#chartImgUrl').val(ret.address)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
$(function () {
|
||||
init();
|
||||
});
|
||||
|
||||
@@ -18,29 +18,31 @@
|
||||
body {
|
||||
overflow: hidden;
|
||||
overflow-y: scroll;
|
||||
background: #f8f8f8;
|
||||
background: white;
|
||||
/** 特别注意,否则中文不生效 **/
|
||||
font-family: SimSun;
|
||||
}
|
||||
.main {
|
||||
margin: 4px 8px 4px 8px;
|
||||
background: #f8f8f8;
|
||||
background: white;
|
||||
}
|
||||
.title {
|
||||
position: relative;
|
||||
color: #1E90FF;
|
||||
}
|
||||
.title1 {
|
||||
font-size: 14px;
|
||||
font-size: 19px;
|
||||
color: #1E90FF;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.p {
|
||||
font-size: 12px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.inline {
|
||||
width: 550px;
|
||||
@@ -109,7 +111,7 @@
|
||||
<div>
|
||||
<#if result.tradesImgUrl??>
|
||||
<#-- <img width="800px" height="300px" src="../static/images/test.png"></img>-->
|
||||
<img width="800px" height="300px" src="${result.tradesImgUrl}"></img>
|
||||
<img width="600px" height="300px" src="${result.tradesImgUrl}"></img>
|
||||
<#else>
|
||||
<div class="p table">
|
||||
<table class="inline">
|
||||
@@ -122,7 +124,7 @@
|
||||
<div>
|
||||
<div class="title1">6 已租房源</div>
|
||||
<div class="p table">
|
||||
<table class="inline">
|
||||
<table class="inline" style="width: 800px">
|
||||
<thead>
|
||||
<tr class="bg">
|
||||
<th class="th01">城市</th>
|
||||
@@ -161,13 +163,13 @@
|
||||
<div>
|
||||
<div class="title1">7 样本参考</div>
|
||||
<div class="p table">
|
||||
<table class="inline">
|
||||
<table class="inline" style="width: 800px">
|
||||
<thead>
|
||||
<tr class="bg">
|
||||
<th class="th01">城市</th>
|
||||
<th>区域</th>
|
||||
<th>小区名</th>
|
||||
<th>租金</th>
|
||||
<th>租 金</th>
|
||||
<th>面积</th>
|
||||
<th>室</th>
|
||||
<th>厅</th>
|
||||
@@ -200,7 +202,7 @@
|
||||
<div>
|
||||
<div class="title1">8 周边同类小区租金</div>
|
||||
<div class="p table">
|
||||
<table class="inline" style="width: 300px">
|
||||
<table class="inline" style="width: 500px">
|
||||
<thead>
|
||||
<tr class="bg">
|
||||
<th class="th01">城市</th>
|
||||
@@ -220,7 +222,7 @@
|
||||
<td><#if bo.districtName??>${bo.districtName}</#if></td>
|
||||
<td><#if bo.totalPrice??>${bo.totalPrice}</#if></td>
|
||||
<td><#if bo.room??>${bo.room}</#if></td>
|
||||
<td><#if bo.hall??>${bo.hall}</#if></td>
|
||||
<td><#if bo.hall??>${bo.hall}<#else>1</#if></td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#else>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user